/** * @param string $retailer_id * @param int $catalog_id * @param array $data * @param array $params * @return bool */ public static function updateProductInCatalogByRetailerId($retailer_id, $catalog_id, array $data = array(), array $params = array()) { $product = new static(); $product->setData($data); $data = Api::instance()->call(self::buildCatalogUrlForRetailerId($retailer_id, $catalog_id), RequestInterface::METHOD_POST, array_merge($product->exportData(), $params))->getContent(); return isset($data['success']) ? $data['success'] : false; }
/** * Create a view and get its content * * @param string Name of view * @param array Data to pass to the view * @return \Kofradia\Viev */ public static function forge($name, $data = array()) { $path = PATH_APP . "/views/{$name}.php"; $view = new static($path); $view->setData($data); return $view->render(); }
public static function create(\Exception $exception, $statusCode = null, array $headers = []) { $e = new static(); $e->setMessage($exception->getMessage()); $e->setCode($exception->getCode()); if ($exception instanceof HttpExceptionInterface) { $statusCode = $exception->getStatusCode(); $headers = array_merge($headers, $exception->getHeaders()); } if (null === $statusCode) { $statusCode = 500; } $e->setStatusCode($statusCode); $e->setHeaders($headers); $e->setTraceFromException($exception); $e->setClass(get_class($exception)); $e->setFile($exception->getFile()); $e->setLine($exception->getLine()); if ($exception->getPrevious()) { $e->setPrevious(static::create($exception->getPrevious())); } if ($exception instanceof SyrupComponentException) { /** @var SyrupComponentException $exception */ $e->setData($exception->getData()); } return $e; }
public static function saveConfig($key, $value) { $value = json_encode($value); /* @var Config $config */ $config = new static(); $config->setData('key', $key)->setData('value', $value)->save(); }
public static function i(array $data = []) { $obj = new static(); $obj->addClass('chartPanel'); $obj->setData($data); $obj->_processData(); return $obj; }
public function make(Response $response) { $upload = new static(); $data = $response->toArray(); $data['uploaded_at'] = new DateTime(); $upload->setData($data); return $upload; }
/** * Insert a template. * * @param string $name The template name. * @param array $data An optional data array. * * @return void */ public function insert($name, array $data = null) { $template = new static($name, $this->helpers, $this->strContentType); if ($data !== null) { $template->setData($data); } echo $template->parse(); }
/** * @param $dataString * @return static */ public static function init($dataString = '') { $class = new static(); if (!empty($dataString)) { $class->setData($dataString); } return $class; }
/** * Set data and clear format. Or provide this request to inner component (decor it) * * @param null|mixed $data - some data * @return null|bConverter__instance - for chaining (used fully decorated component which stored in parent property) */ public final function setData($data = null) { if ($this->_component !== null) { return $this->_component->setData($data); } $this->_data = $data; $this->_format = null; return $this->_parent->output(); }
/** * @return static */ public static function getInstance() { if (!self::isSessionStarted()) { session_start(); } /** @var Session $session */ $session = new static(); $session->setData($_SESSION); return $session; }
/** * Atribui uma array de configurações * @param array $data * @return void */ public function setData(array $data) { foreach ($data as $key => $value) { if (is_array($value)) { $config = new static(); $config->setData($value); $this->data[$key] = $config; } else { $this->data[$key] = $value; } } }
/** * Get object by domain * * If no unused object exists in the database a * new blank object will be returned * * @param string domain * @param \user * @return \Kofradia\Form */ public static function getByDomain($domain, \user $user) { $result = DB::get()->prepare("\n\t\t\tSELECT " . static::$databaseFields . "\n\t\t\tFROM forms\n\t\t\tWHERE forms_area = ? AND forms_u_id = ? AND forms_attempts = 0\n\t\t\tLIMIT 1"); $result->execute(array($domain, $user->id)); $f = new static(); $f->setUser($user); $f->setDomain($domain); if ($row = $result->fetch()) { $f->setData($row); } return $f; }
/** * Process resultset from database * * @param \PDOStatement */ public static function fetchRanksProcessResult(\PDOStatement $result) { $last = null; $i = 1; while ($row = $result->fetch()) { $rank = new static(); $rank->setData($row); $rank->setNum($i); static::$by_number[$i] = $rank; if ($last) { $rank->setPrev($last); $last->setNext($rank); } $last = $rank; $i++; } }
/** * @param string $query * @param string $type * @param string $class * @param array $params * @param Api $api * @return Cursor * @throws \InvalidArgumentException */ public static function search($type, $class = null, $query = null, array $params = array(), Api $api = null) { $api = $api ?: Api::instance(); if (!$api) { throw new \InvalidArgumentException('An Api instance must be provided as argument or ' . 'set as instance in the \\FacebookAds\\Api'); } $params = array_merge($params, array('type' => $type, 'class' => $class, 'q' => $query)); $response = $api->call('/search', Api::HTTP_METHOD_GET, $params); $result = array(); foreach ($response->getResponse()->{'data'} as $data) { /** @var $object AbstractObject */ $object = new static(); if (is_object($data)) { $data = get_object_vars($data); } $object->setData($data); $result[] = $object; } return new Cursor($result, $response); }
/** * Factory helper * * @param array $data * @return array */ public static function cleanData($data, $allowed) { $cls = new static(); $cls->setData($data, $allowed); return $cls->clean(); }
/** * Static shortcut method for instantiating a new instance of the View class * Makes it prettier and quicker to use * * @access public * @param string The name of the view file, sans the extension * @param array Any data to be passed in the view * @return Propeller\View object */ public static function make($view, array $data = array()) { $obj = new static($view); $obj->setData($data); return $obj; }
/** * Insert a template * * @param string $name The template name * @param array $data An optional data array */ public function insert($name, array $data = null) { $tpl = new static($name); if ($data !== null) { $tpl->setData($data); } echo $tpl->parse(); }
/** * Read function for the object. Convert fields and filters into the query * part of uri and return objects. * * @param mixed $ids Array or single object IDs * @param array $fields Array of field names to read * @param array $params Additional filters for the reading, in assoc * @param Api $api Api Object to use * @return Cursor */ public static function readIds(array $ids, array $fields = array(), array $params = array(), Api $api = null) { if (empty($fields)) { $fields = static::getDefaultReadFields(); } if (!empty($fields)) { $params['fields'] = implode(',', $fields); } $params['ids'] = implode(',', $ids); $api = static::assureApi($api); $response = $api->call('/', RequestInterface::METHOD_GET, $params); $result = array(); foreach ($response->getContent() as $data) { /** @var AbstractObject $object */ $object = new static(null, null, $api); $object->setData((array) $data); $result[] = $object; } return $result; }
/** * Will create a new entity (also in database) * * QuickORM::create('first', null, 2); * QuickORM::create(array('first', null, 2)); * QuickORM::create(array(1 => 'first', 2 => null, 3 => 2)); * QuickORM::create(array('firstDBCol' => 'first', 'secondDBCol' => null, 'thirdDBCol' => 2)); * * @param $data Data for new entity * * @return static The created entity */ public static function create($data) { $object = new static(); $object->setData(is_array($data) ? $data : func_get_args()); $object->store(); return $object; }
/** * Parse raw HTTP response string * * @param string $raw * HTTP raw response * * @return \Zuora\Http\Response */ public static function fromString($raw) { $response = new static(); // Parse response to headers and body $pos = strrpos($raw, "\r\n\r\n"); if (false !== $pos) { $headers = explode("\r\n", trim(substr($raw, 0, $pos))); if (preg_match('~^HTTP/1\\.[01] (?<code>\\d+).*$~i', $headers[0], $matches)) { array_shift($headers); $response->setCode($matches['code']); } $response->setHeaders($headers); $data = trim(substr($raw, $pos + 4)); $response->setData($data); } return $response; }
/** * Read function for the object. Convert fields and filters into the query * part of uri and return objects. * * @param mixed $ids Array or single object IDs * @param array $fields Array of field names to read * @param array $params Additional filters for the reading, in assoc * @param Api $api Api Object to use * @return Cursor */ public static function readIds(array $ids, array $fields = array(), array $params = array(), Api $api = null) { if (!$fields) { $fields = static::getDefaultReadFields(); } if ($fields) { $params['fields'] = implode(',', $fields); } $params['ids'] = implode(',', $ids); $api = static::assureApi($api); $response = $api->call('/', Api::HTTP_METHOD_GET, $params); $result = array(); foreach ($response->getResponse() as $data) { /** @var AbstractObject $object */ $object = new static(null, null, $api); $object->setData((array) $data); $result[] = $object; } return new Cursor($result, $response); }
/** * @param $data * @return mixed */ public static function fromData($data) { $instance = new static(); return $instance->setData($data); }
/** * @param mixed $data * @return static */ public static function create($data) { $command = new static(); $command->setData($data); return $command; }
/** * Creates an instance of image from its data. */ public static function fromData($data) { $image = new static(); $image->setData($data); return $image; }
/** * Collection Factory */ protected static function makeCollection($results) { // Make Collection $collection = new Collection(); foreach ($results as $row) { // Create new Model $model = new static(); $model->setData($row->{static::$key}, (array) $row); // Add Model to Collection $collection->add($model); } return $collection; }
/** * Creates a child node * @return static */ public function createChild($data, $exists = true) { $child = new static(); $child->setData($data); $child->exists = $exists; $child->context = $this; $child->origin = $this->origin ?: $this; return $child; }
public static function all($where_clause = []) { // Create an SQL "WHERE" clause $sql_where = Sql::where($where_clause); // SQL $sql = "\n SELECT * FROM " . static::$table . $sql_where; // Get Results $results = DB::select($sql, $where_clause); // Make Collection $collection = new Collection(); foreach ($results as $row) { // Create new Model $model = new static(); $model->setData($row->{static::$key}, (array) $row); // Add Model to Collection $collection->add($model); } return $collection; }
public static function responseData($data, $msg = null) { $response = new static(); $response->setData($data); if ($msg != null) { $response->setMessage($msg); } return $response->response(); }