Jarves\Objects::getPrimaryList PHP Method

getPrimaryList() public method

Returns array('', '', ...);
public getPrimaryList ( $objectId ) : array
$objectId
return array
    public function getPrimaryList($objectId)
    {
        $objectDefinition = $this->getDefinition($objectId);
        $primaryFields = array();
        foreach ($objectDefinition->getFields() as $fieldKey => $field) {
            if ($field->getPrimaryKey()) {
                $primaryFields[] = $fieldKey;
            }
        }
        return $primaryFields;
    }

Usage Example

Example #1
0
 /**
  * Get a condition object for item listings.
  *
  * @param  string $objectKey
  *
  * @return Condition
  */
 public function getListingCondition($objectKey)
 {
     $objectKey = Objects::normalizeObjectKey($objectKey);
     $obj = $this->objects->getStorageController($objectKey);
     $rules = self::getRules($objectKey, static::MODE_LISTING);
     if (count($rules) === 0) {
         return null;
     }
     if ($this->getCaching()) {
         $cacheKey = md5($objectKey);
         $cached = $this->cacher->getDistributedCache('core/acl/listing/' . $cacheKey);
         if (null !== $cached) {
             return $cached;
         }
     }
     $condition = '';
     $primaryList = $this->objects->getPrimaryList($objectKey);
     $primaryKey = current($primaryList);
     $denyList = array();
     $conditionObject = new Condition(null, $this->jarves);
     foreach ($rules as $rule) {
         if ($rule['constraint_type'] === ACL::CONSTRAINT_EXACT) {
             //todo $rule['constraint_code'] can be a (urlencoded) composite pk
             //todo constraint_code is always urlencoded;
             $condition = Condition::create(array($primaryKey, '=', Tools::urlDecode($rule['constraint_code'])), $this->jarves);
         }
         if ($rule['constraint_type'] === ACL::CONSTRAINT_CONDITION) {
             $condition = Condition::create($rule['constraint_code'], $this->jarves);
         }
         if ($rule['constraint_type'] === ACL::CONSTRAINT_ALL) {
             $condition = array('1', '=', '1');
         } elseif ($rule['sub']) {
             $subCondition = $obj->getNestedSubCondition($condition);
             if ($subCondition) {
                 $condition = array($condition, 'OR', $subCondition);
             }
         }
         if ($rule['access'] === 1) {
             if ($denyList) {
                 $condition = array($condition, 'AND NOT', $denyList);
                 $conditionObject->addOr($condition);
                 //                    $conditionObject->add('AND NOT', $denyList);
             } else {
                 $conditionObject->addOr($condition);
             }
         }
         if ($rule['access'] !== 1) {
             if ($denyList) {
                 $denyList[] = 'AND NOT';
             }
             $denyList[] = $condition;
         }
     }
     if (!$conditionObject->hasRules()) {
         $conditionObject->addAnd(array('1', '!=', '1'));
     }
     if ($this->getCaching()) {
         $cacheKey = md5($objectKey);
         $this->cacher->setDistributedCache('core/acl/listing/' . $cacheKey, $conditionObject);
     }
     return $conditionObject;
 }
All Usage Examples Of Jarves\Objects::getPrimaryList