Jarves\Objects::get PHP Method

get() public method

$options is a array which can contain following options. All options are optional. 'fields' Limit the columns selection. Use a array or a comma separated list (like in SQL SELECT) If empty all columns will be selected. 'offset' Offset of the result set (in SQL OFFSET) 'limit' Limits the result set (in SQL LIMIT) 'order' The column to order. Example: array( array('field' => 'category', 'direction' => 'asc'), array('field' => 'title', 'direction' => 'asc') ) 'foreignKeys' Define which column should be resolved. If empty all columns will be resolved. Use a array or a comma separated list (like in SQL SELECT) 'permissionCheck' Defines whether we check against the ACL or not. true or false. default false
public get ( string $objectKey, mixed $pk, array $options = [] ) : array | null
$objectKey string
$pk mixed
$options array
return array | null
    public function get($objectKey, $pk, $options = array())
    {
        $repository = $this->getRepository($objectKey, $options);
        return $repository->getItem($pk);
    }

Usage Example

Example #1
0
 /**
  * {@inheritdoc}
  */
 public function getParents($pk, $options = null)
 {
     $query = $this->getQueryClass();
     $item = $query->findPK($this->getPropelPk($pk));
     if (!$item) {
         throw new \Exception('Can not found entry. ' . var_export($pk, true));
     }
     if (!$item->getRgt()) {
         throw new \Exception('Entry it not in a tree. ' . var_export($pk, true));
     }
     list($fields, $relations, $relationFields) = $this->getFields(@$options['fields']);
     $selects = array_keys($fields);
     $selects[] = 'Lft';
     $selects[] = 'Rgt';
     //        $selects[] = 'Title';
     $query->select($selects);
     $this->mapOptions($query, $options);
     $this->mapToOneRelationFields($query, $relations, $relationFields);
     $query->ancestorsOf($item);
     $query->orderByLevel();
     $stmt = $this->getStm($query);
     $clazz = $this->getPhpName();
     $result = array();
     if ($this->definition['nestedRootAsObject']) {
         //fetch root object entry
         $scopeField = 'get' . ucfirst($this->definition['nestedRootObjectField']);
         $scopeId = $item->{$scopeField}();
         $root = $this->objects->get($this->definition['nestedRootObject'], $scopeId);
         $root['_object'] = $this->definition['nestedRootObject'];
         $result[] = $root;
     }
     $item = false;
     while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
         //propels nested set requires a own root item, we do not return this
         if (false === $item) {
             $item = true;
             continue;
         }
         $item = $this->populateRow($clazz, $row, $selects, $relations, $relationFields, $options['permissionCheck']);
         $result[] = $item;
     }
     return $result;
 }
All Usage Examples Of Jarves\Objects::get