Ejemplo n.º 1
0
 /**
  * Load data from array
  *
  * @param array $data
  * @return bool
  */
 protected function loadArray(array $data) : bool
 {
     // Value check
     $keys = Arrays::arrayForKey($data, static::KEY_KEYS);
     $values = Arrays::arrayForKey($data, static::KEY_VALUES);
     if (is_null($keys) || is_null($values) || count($keys) !== count($values)) {
         return false;
     }
     // Load
     $this->keys = $keys;
     $this->values = $values;
     return true;
 }
Ejemplo n.º 2
0
 /**
  * {@inheritDoc}
  * @see \Fixin\Model\Repository\RepositoryInterface::save($entity)
  */
 public function save(EntityInterface $entity) : EntityIdInterface
 {
     $set = $entity->collectSaveData();
     if ($oldId = $entity->getEntityId()) {
         $request = $this->createRequest();
         $request->getWhere()->id($oldId);
         $this->getStorage()->update($set, $request);
         $id = array_replace($oldId->getArrayCopy(), Arrays::intersectByKeys($set, $this->primaryKey));
         if ($id === $oldId->getArrayCopy()) {
             return $oldId;
         }
         $this->getEntityCache()->remove($entity);
         return $this->createIdWithArray($id);
     }
     return $this->insert($set);
 }
Ejemplo n.º 3
0
 /**
  * Add route item to the results
  *
  * @param array $path
  * @param string $uri
  * @param array $parameters
  */
 protected function addRouteItem(array $path, string $uri, array $parameters)
 {
     Arrays::set($this->routeTree, $path, [HttpRouterHub::KEY_HANDLER => $this->scopeName, HttpRouterHub::KEY_PARAMETERS => array_keys($parameters)]);
     $this->routeUris[$this->scopeName] = [HttpRouterHub::KEY_URI => $uri, HttpRouterHub::KEY_PARAMETERS => $parameters];
 }