コード例 #1
0
 /**
  * Возвращает обязательное поле коллекции.
  * @param $fieldName
  * @throws NonexistentEntityException если поле не существует
  * @return IField
  */
 protected function getRequiredField($fieldName)
 {
     if (!$this->metadata->getFieldExists($fieldName)) {
         throw new NonexistentEntityException($this->translate('Collection "{collection}" does not contain required field "{name}".', ['collection' => $this->name, 'name' => $fieldName]));
     }
     return $this->metadata->getField($fieldName);
 }
コード例 #2
0
ファイル: Selector.php プロジェクト: umisoft/umi.framework
 /**
  * {@inheritdoc}
  */
 public function fields(array $fieldNames = [])
 {
     foreach ($fieldNames as $fieldName) {
         if ($this->metadata->getFieldExists($fieldName)) {
             $field = $this->metadata->getField($fieldName);
             $this->fields[$fieldName] = $field;
         } else {
             throw new NonexistentEntityException($this->translate('Cannot select objects. Field "{name}" does not exist.', ["name" => $fieldName]));
         }
     }
     return $this;
 }