public function getPublisher() { if (!$this->source['p_id']) throw new MMSynchException('Variable "p_id" not set in source'); if (!$this->publisher) { $this->publisher = MMSynchPublisherFolder::fetch($this->source['p_id']); } return $this->publisher; }
protected function synchronize() { parent::synchronize(); $locale = $this->source['m_language']; $this->content = SQLIContent::create(new SQLIContentOptions( array( 'class_identifier' => self::$class_identifier, 'remote_id' => $this->remoteId(), 'language' => $locale ))); // Positionnement sous le publisher $publisher = MMSynchPublisherFolder::fetch($this->source['p_id']); MMSynchHelper::addLocation($this->content, $publisher->getContentMediaFile()->defaultLocation); if (!isset($this->content->fields[$locale])) $this->content->addTranslation($locale); $this->content->setActiveLanguage($locale); $this->populate(); $this->publish(); }
/** * Adds an application folder to the publisher folder if it's not yet added * @param mixed $applicationId * @param mixed $publisherFolderId * @param eZCLI $cli */ function alignApplicationWithPublisherFolder( $applicationId, $publisherFolderId, eZCLI $cli ) { $application = $applicationId; $publisherFolder = $publisherFolderId; if (! $application instanceof ApplicationLocalized ) { $application = ApplicationLocalized::getLocalizedApplicationById( $applicationId, false ); } if ( $application == null ) { throw new Exception( "Application localized with id {$applicationId} does not exist." ); } if (! $publisherFolder instanceof MMSynchPublisherFolder ) { $publisherFolder = MMSynchPublisherFolder::fetch( $publisherFolderId ); } if ( $publisherFolder == null ) { throw new Exception( "Publisher folder with id {$publisherFolderId} does not exist." ); } $remoteId = 'application_folder-' . $application->cluster_identifier . '-' . $application->applicationObject->identifier; $applicationFolderObject = eZContentObject::fetchByRemoteID( $remoteId ); if ( $applicationFolderObject == null ) { throw new Exception( "Application folder object with remote id {$remoteId} doesn't exist" ); } $applicationFolderId = $applicationFolderObject->attribute( 'id' ); //use getContent with true to create problems $path = $publisherFolder->getContent( )->fields->path->toString(); if ( $path ) { $contentobject = $publisherFolder->getContent()->getRawContentObject(); $languages = $contentobject->availableLanguages(); foreach ( $languages as $language ) { $dataMap = $contentobject->dataMap(); $contentObjectAttributeTargetCS = $dataMap['target_cs']; $objectIds = explode( '-', $contentObjectAttributeTargetCS->toString() ); if ( !in_array( $applicationFolderId, $objectIds ) ) { $objectIds[] = $applicationFolderId; $contentObjectAttributeTargetCS->fromString( implode( '-', $objectIds ) ); $contentObjectAttributeTargetCS->store(); } else { $cli->notice( "Ommiting application folder with path {$remoteId}" ); } } } }
{ $replies = $cli->askQuestionMultipleChoices( 'Choose publisher folders you want to create', $folders, 'validateReplyMultiple', true ); } if (!empty($replies)) { foreach ($replies as $key) { try { $object = MMSynchPublisherFolder::fetch($key); $path = $object->getContent(true)->fields->path->toString(); } catch (Exception $e) { echo $e->getTraceAsString() . "\n"; echo "Error : " . $e->getMessage() . "\n"; } } } } else { echo "No new publisher folder to create\n"; }