Gc\Property\Collection::getProperties PHP Method

getProperties() public method

Get properties
public getProperties ( boolean $forceReload = false ) : array
$forceReload boolean to initiliaze properties
return array
    public function getProperties($forceReload = false)
    {
        if ($this->getData('properties') == null or $forceReload) {
            $select = new Select();
            $select->from('tab')->columns(array())->join('property', 'tab.id = property.tab_id', '*', Select::JOIN_INNER);
            if ($this->getDocumentId() !== null) {
                $select->join('document', 'document.document_type_id = tab.document_type_id', array(), Select::JOIN_INNER);
                $select->join('property_value', 'document.id = property_value.document_id AND property.id = property_value.property_id', array('value'), Select::JOIN_LEFT);
                $select->where(array('document.id' => $this->getDocumentId()));
            }
            if ($this->getTabId() != null) {
                $select->where(array('tab.id' => $this->getTabId()));
            }
            if ($this->getDocumentTypeId() != null) {
                $select->where(array('tab.document_type_id' => $this->getDocumentTypeId()));
            }
            $select->order('property.sort_order ASC');
            $rows = $this->fetchAll($select);
            $properties = array();
            foreach ($rows as $row) {
                $propertyModel = Model::fromArray((array) $row);
                if ($this->getDocumentId() !== null) {
                    $propertyModel->setDocumentId($this->getDocumentId());
                }
                $properties[] = $propertyModel;
            }
            $this->setData('properties', $properties);
        }
        return $this->getData('properties');
    }

Usage Example

Beispiel #1
0
 /**
  * Test
  *
  * @return void
  */
 public function testGetProperties()
 {
     $documentModel = DocumentModel::fromArray(array('name' => 'DocumentTest', 'url_key' => 'document-test', 'status' => DocumentModel::STATUS_ENABLE, 'sort_order' => 1, 'show_in_nav' => true, 'user_id' => $this->user->getId(), 'document_type_id' => $this->documentType->getId(), 'view_id' => $this->view->getId(), 'layout_id' => $this->layout->getId(), 'parent_id' => 0));
     $documentModel->save();
     $this->object->setDocumentId($documentModel->getId());
     $this->object->save();
     $this->object->load($this->documentType->getId(), $this->tab->getId(), 1);
     $this->assertInternalType('array', $this->object->getProperties(true));
     $this->object->load();
     $this->assertInternalType('array', $this->object->getProperties(true));
 }
All Usage Examples Of Gc\Property\Collection::getProperties