/** * {@inheritdoc} */ public function getMetadata($collectionName) { if (isset($this->metadataInstances[$collectionName])) { return $this->metadataInstances[$collectionName]; } if (!$this->hasMetadata($collectionName)) { throw new NonexistentEntityException($this->translate('Cannot get metadata. Metadata for collection "{collection}" does not exist.', ['collection' => $collectionName])); } $metadata = $this->metadataFactory->create($collectionName, $this->metadata[$collectionName]); return $this->metadataInstances[$collectionName] = $metadata; }
/** * {@inheritdoc} */ public function getField($fieldName) { if (isset($this->fields[$fieldName])) { return $this->fields[$fieldName]; } if (!$this->getFieldExists($fieldName)) { throw new NonexistentEntityException($this->translate('Field "{name}" does not exist in "{collection}".', ['name' => $fieldName, 'collection' => $this->getCollectionName()])); } $config = $this->config['fields'][$fieldName]; $config['collectionName'] = $this->collectionName; $field = $this->metadataFactory->createField($fieldName, $config); return $this->fields[$fieldName] = $field; }