/** * @param ContentTypeInterface $contentType * * @return FacadeInterface * * @throws TransformerParameterTypeException */ public function transform($contentType) { if (!$contentType instanceof ContentTypeInterface) { throw new TransformerParameterTypeException(); } $facade = $this->newFacade(); $facade->id = $contentType->getId(); $facade->contentTypeId = $contentType->getContentTypeId(); $facade->name = $this->multiLanguagesChoiceManager->choose($contentType->getNames()); $facade->version = $contentType->getVersion(); $facade->linkedToSite = $contentType->isLinkedToSite(); if ($this->hasGroup(CMSGroupContext::FIELD_TYPES)) { foreach ($contentType->getFields() as $field) { $facade->addField($this->getTransformer('field_type')->transform($field)); } } $facade->addLink('_self', $this->generateRoute('open_orchestra_api_content_type_show', array('contentTypeId' => $contentType->getContentTypeId()))); if (0 == $this->contentRepository->countByContentType($contentType->getContentTypeId()) && $this->authorizationChecker->isGranted(AdministrationPanelStrategy::ROLE_ACCESS_DELETE_CONTENT_TYPE)) { $facade->addLink('_self_delete', $this->generateRoute('open_orchestra_api_content_type_delete', array('contentTypeId' => $contentType->getContentTypeId()))); } if ($this->authorizationChecker->isGranted(AdministrationPanelStrategy::ROLE_ACCESS_UPDATE_CONTENT_TYPE)) { $facade->addLink('_self_form', $this->generateRoute('open_orchestra_backoffice_content_type_form', array('contentTypeId' => $contentType->getContentTypeId()))); } return $facade; }
/** * @param ContentTypeInterface $value * @param UniqueContentTypeId|Constraint $constraint */ public function validate($value, Constraint $constraint) { $result = $this->repository->findOneByContentTypeIdInLastVersion($value->getContentTypeId()); if (null !== $result && $value->getVersion() <= 1) { $this->context->buildViolation($constraint->message)->atPath('contentTypeId')->addViolation(); } }
/** * Create a elasticSearch linked to the object * * @param null|ContentTypeInterface $contentType */ public function createMapping($contentType) { $index = $this->client->getIndex($this->indexName); $type = $index->getType(self::INDEX_TYPE . $contentType->getContentTypeId()); $mappingProperties = array('id' => array('type' => 'string', 'include_in_all' => true), 'elementId' => array('type' => 'string', 'include_in_all' => true), 'contentId' => array('type' => 'string', 'include_in_all' => true), 'name' => array('type' => 'string', 'include_in_all' => true), 'siteId' => array('type' => 'string', 'include_in_all' => true), 'linkedToSite' => array('type' => 'boolean', 'include_in_all' => false), 'language' => array('type' => 'string', 'include_in_all' => true), 'contentType' => array('type' => 'string', 'include_in_all' => true), 'keywords' => array('type' => 'string', 'include_in_all' => true), 'updatedAt' => array('type' => 'long', 'include_in_all' => false)); /** @var FieldTypeInterface $field */ foreach ($contentType->getFields() as $field) { if ($field->isSearchable()) { $mappingProperties['attribute_' . $field->getFieldId()] = array('type' => $this->formMapper->map($field->getType()), 'include_in_all' => false); $mappingProperties['attribute_' . $field->getFieldId() . '_stringValue'] = array('type' => 'string', 'include_in_all' => true); } } $mapping = $this->mappingFactory->create($type); $mapping->setProperties($mappingProperties); $mapping->send(); }
/** * @param string $message * @param ContentTypeInterface $contentType */ protected function sendLog($message, ContentTypeInterface $contentType) { $this->logger->info($message, array('content_type_id' => $contentType->getContentTypeId(), 'content_type_name' => $contentType->getName($this->context->getCurrentLocale()))); }