/** * @param string $clover * @param string $target * @param string $templatePath * * @throws \InvalidArgumentException */ public function convert($clover, $target, $templatePath = false) { if (is_file($clover) === false) { throw new \InvalidArgumentException(sprintf('"%s" is not a file', $clover)); } if (is_dir($target) === true) { throw new \InvalidArgumentException(sprintf('Target must be empty "%s"', $target)); } $this->render->render($this->hydrator->xmlToDto(simplexml_load_file($clover), new Root()), $target, $templatePath); }
/** * Add a product(s) to cart * * @param array $items * @return true */ public function insert(array $items) { if (!is_array($items) or empty($items)) { throw new \Exception('Only correct values could be saved in Shopping cart.'); } if (!is_array($this->session['cart'])) { $this->session['cart'] = array(); } if ($this->isMultidimention($items)) { foreach ($items as $item) { $this->session['cart'][$this->generateToken($item)] = $this->hydrator->hydrate($item, new $this->entityPrototype()); } } else { $this->session['cart'][$this->generateToken($items)] = $this->hydrator->hydrate($items, $this->entityPrototype); } return true; }
/** * Sync the fields from entity --> proxy * * @param array $properties */ public function syncFromEntity(array $properties = null) { if (!$properties) { $properties = $this->syncedProperties; } $this->hydrator->transfer($this->entity, $this, $properties); }
/** * @param array $fields * @return array */ public function _get($fields = array()) { $results = $this->connection->find(static::$collection, $this->_where, $fields); $this->_count = $results->count(); if (!is_null($this->_limit)) { $results->limit($this->_limit); } if (!is_null($this->_skip)) { $results->skip($this->_skip); } if (!empty($this->_sort)) { $results->sort($this->_sort); } return Hydrator::hydrate($this, $results); }