idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
10,900
public function getPlural ( $ Number , $ String ) { if ( isset ( $ this -> Data [ $ String ] ) ) { $ Choices = $ this -> Data [ $ String ] ; $ IntegerRule = $ this -> IntegerRule ; $ FractionRule = $ this -> FractionRule ; } elseif ( isset ( $ this -> Fallback [ $ String ] ) ) { $ Choices = $ this -> Fallback [ $ String ] ; $ IntegerRule = $ this -> FallbackIntegerRule ; $ FractionRule = $ this -> FallbackFractionRule ; } else { return '' ; } if ( ! is_array ( $ Choices ) ) { return $ Choices ; } if ( is_float ( $ Number ) ) { $ Choice = $ this -> { $ FractionRule } ( $ Number ) ; } elseif ( is_int ( $ Number ) ) { $ Choice = $ this -> { $ IntegerRule } ( $ Number ) ; } else { $ Choice = 0 ; } if ( isset ( $ Choices [ $ Choice ] ) ) { return $ Choices [ $ Choice ] ; } return isset ( $ Choices [ 0 ] ) ? $ Choices [ 0 ] : '' ; }
Fetch an L10N string from a range of possible plural forms .
10,901
public function getString ( $ String ) { if ( isset ( $ this -> Data [ $ String ] ) ) { return $ this -> Data [ $ String ] ; } return isset ( $ this -> Fallback [ $ String ] ) ? $ this -> Fallback [ $ String ] : '' ; }
Safely fetch an L10N string .
10,902
private function normaliseValue ( & $ Value , $ ValueLen , $ ValueLow ) { foreach ( [ [ '"' , '"' , 1 ] , [ "'" , "'" , 1 ] , [ '`' , '`' , 1 ] , [ "\x91" , "\x92" , 1 ] , [ "\x93" , "\x94" , 1 ] , [ "\xe2\x80\x98" , "\xe2\x80\x99" , 3 ] , [ "\xe2\x80\x9c" , "\xe2\x80\x9d" , 3 ] ] as $ Wrapper ) { if ( substr ( $ Value , 0 , $ Wrapper [ 2 ] ) === $ Wrapper [ 0 ] && substr ( $ Value , $ ValueLen - $ Wrapper [ 2 ] ) === $ Wrapper [ 1 ] ) { $ Value = substr ( $ Value , $ Wrapper [ 2 ] , $ ValueLen - ( $ Wrapper [ 2 ] * 2 ) ) ; return ; } } if ( $ ValueLow === 'true' || $ ValueLow === 'y' ) { $ Value = true ; } elseif ( $ ValueLow === 'false' || $ ValueLow === 'n' ) { $ Value = false ; } elseif ( substr ( $ Value , 0 , 2 ) === '0x' && ( $ HexTest = substr ( $ Value , 2 ) ) && ! preg_match ( '/[^\da-f]/i' , $ HexTest ) && ! ( $ ValueLen % 2 ) ) { $ Value = hex2bin ( $ HexTest ) ; } elseif ( preg_match ( '~^\d+$~' , $ Value ) ) { $ Value = ( int ) $ Value ; } elseif ( preg_match ( '~^\d+\.\d+$~' , $ Value ) ) { $ Value = ( float ) $ Value ; } elseif ( ! $ ValueLen ) { $ Value = false ; } else { $ Value = ( string ) $ Value ; } }
Normalises the values defined by the processLine method .
10,903
private function TryX ( $ Using ) { if ( ! function_exists ( $ Using ) ) { return 1 ; } $ Try = $ Using ( $ this -> Data ) ; if ( $ Try !== false && is_string ( $ Try ) ) { $ this -> Data = $ Try ; return 0 ; } return 2 ; }
The basis for the other try methods .
10,904
public function TryEverything ( ) { $ Original = $ this -> Data ; $ Errors = & $ this -> Errors ; set_error_handler ( function ( $ errno , $ errstr , $ errfile , $ errline ) use ( & $ Errors ) { $ Errors [ ] = [ $ errno , $ errstr , $ errfile , $ errline ] ; } ) ; while ( true ) { if ( $ this -> TryGz ( ) === 0 ) { continue ; } if ( $ this -> TryBz ( ) === 0 ) { continue ; } if ( $ this -> TryLzf ( ) === 0 ) { continue ; } break ; } restore_error_handler ( ) ; return ( $ Original === $ this -> Data ) ; }
Try everything .
10,905
public function EntryCRC ( ) { return ( isset ( $ this -> StatIndex [ 'crc' ] ) && is_int ( $ this -> StatIndex [ 'crc' ] ) ) ? dechex ( $ this -> StatIndex [ 'crc' ] ) : false ; }
Return the reported internal CRC hash for the entry if it exists .
10,906
public function EntryIsDirectory ( ) { $ Name = $ this -> EntryName ( ) ; return ( ( substr ( $ Name , - 1 , 1 ) === "\\" || substr ( $ Name , - 1 , 1 ) === '/' ) && $ this -> EntryActualSize === 0 ) ; }
Return whether the entry at the current entry pointer is a directory .
10,907
private function mapParent ( $ document , NodeInterface $ node , $ options = [ ] ) { $ targetNode = $ node -> getParent ( ) ; if ( ! $ targetNode -> hasProperty ( 'jcr:uuid' ) ) { return ; } $ document -> setParent ( $ this -> proxyFactory -> createProxyForNode ( $ document , $ targetNode , $ options ) ) ; }
Map parent document to given document .
10,908
private function getImageUrl ( $ media , $ locale ) { $ mediaApi = new Media ( $ media , $ locale ) ; $ this -> mediaManager -> addFormatsAndUrl ( $ mediaApi ) ; $ formats = $ mediaApi -> getThumbnails ( ) ; if ( ! isset ( $ formats [ $ this -> searchImageFormat ] ) ) { $ this -> logger -> warning ( sprintf ( 'Media with ID "%s" does not have thumbnail format "%s". This thumbnail would be used by the search results.' , $ media -> getId ( ) , $ this -> searchImageFormat ) ) ; return ; } return $ formats [ $ this -> searchImageFormat ] ; }
Return the image URL for the given media .
10,909
public function removeSystemFields ( ) { $ properties = $ this -> fields ; unset ( $ properties [ 'created' ] , $ properties [ 'changed' ] , $ properties [ 'changer' ] , $ properties [ 'changer_id' ] , $ properties [ 'creator' ] , $ properties [ 'creator_id' ] ) ; foreach ( $ properties as $ key => $ field ) { if ( '__' == substr ( $ key , 0 , 2 ) ) { continue ; } $ this -> properties [ $ key ] = $ field -> getValue ( ) ; } }
Called by the JMS Serializer before the document is serialized for the web API .
10,910
public function find ( $ identifier ) { try { if ( UUIDHelper :: isUUID ( $ identifier ) ) { return $ this -> session -> getNodeByIdentifier ( $ identifier ) ; } return $ this -> session -> getNode ( $ identifier ) ; } catch ( RepositoryException $ e ) { throw new DocumentNotFoundException ( sprintf ( 'Could not find document with ID or path "%s"' , $ identifier ) , null , $ e ) ; } }
Find a document with the given path or UUID .
10,911
public function has ( $ identifier ) { $ this -> normalizeToPath ( $ identifier ) ; try { $ this -> find ( $ identifier ) ; return true ; } catch ( DocumentNotFoundException $ e ) { return false ; } }
Determine if a node exists at the specified path or if a UUID is given then if a node with the UUID exists .
10,912
public function remove ( $ identifier ) { $ identifier = $ this -> normalizeToPath ( $ identifier ) ; $ this -> session -> removeItem ( $ identifier ) ; }
Remove the document with the given path or UUID .
10,913
public function createPath ( $ path ) { $ current = $ this -> session -> getRootNode ( ) ; $ segments = preg_split ( '#/#' , $ path , null , PREG_SPLIT_NO_EMPTY ) ; foreach ( $ segments as $ segment ) { if ( $ current -> hasNode ( $ segment ) ) { $ current = $ current -> getNode ( $ segment ) ; } else { $ current = $ current -> addNode ( $ segment ) ; $ current -> addMixin ( 'mix:referenceable' ) ; $ current -> setProperty ( 'jcr:uuid' , UUIDHelper :: generateUUID ( ) ) ; } } return $ current ; }
Create a path .
10,914
private function normalizeToPath ( $ identifier ) { if ( UUIDHelper :: isUUID ( $ identifier ) ) { $ identifier = $ this -> session -> getNodeByIdentifier ( $ identifier ) -> getPath ( ) ; } return $ identifier ; }
Normalize the given path or ID to a path .
10,915
private function handleOverwrite ( KeywordInterface $ keyword , CategoryInterface $ category ) { if ( null !== $ synonym = $ this -> findSynonym ( $ keyword ) ) { if ( $ this -> entityManager -> contains ( $ keyword ) ) { $ this -> entityManager -> refresh ( $ keyword ) ; } $ this -> delete ( $ keyword , $ category ) ; $ keyword = $ synonym ; } $ categoryTranslation = $ category -> findTranslationByLocale ( $ keyword -> getLocale ( ) ) ; if ( ! $ categoryTranslation ) { $ categoryTranslation = $ this -> createTranslation ( $ category , $ keyword -> getLocale ( ) ) ; } if ( $ categoryTranslation -> hasKeyword ( $ keyword ) ) { return $ keyword ; } $ keyword -> addCategoryTranslation ( $ categoryTranslation ) ; $ categoryTranslation -> addKeyword ( $ keyword ) ; $ category -> setChanged ( new \ DateTime ( ) ) ; $ categoryTranslation -> setChanged ( new \ DateTime ( ) ) ; return $ keyword ; }
Overwrites given keyword .
10,916
private function handleDetach ( KeywordInterface $ keyword , CategoryInterface $ category ) { $ keywordString = $ keyword -> getKeyword ( ) ; $ keywordLocale = $ keyword -> getLocale ( ) ; $ this -> entityManager -> refresh ( $ keyword ) ; $ this -> delete ( $ keyword , $ category ) ; $ newEntity = $ this -> keywordRepository -> createNew ( ) ; $ newEntity -> setKeyword ( $ keywordString ) ; $ newEntity -> setLocale ( $ keywordLocale ) ; return $ this -> save ( $ newEntity , $ category ) ; }
Detach given and create new keyword entity .
10,917
private function findSynonym ( KeywordInterface $ keyword ) { return $ this -> keywordRepository -> findByKeyword ( $ keyword -> getKeyword ( ) , $ keyword -> getLocale ( ) ) ; }
Find the same keyword in the database or returns null if no synonym exists .
10,918
private function createTranslation ( CategoryInterface $ category , $ locale ) { $ categoryTranslation = $ this -> categoryTranslationRepository -> createNew ( ) ; $ categoryTranslation -> setLocale ( $ locale ) ; $ categoryTranslation -> setTranslation ( '' ) ; $ categoryTranslation -> setCategory ( $ category ) ; $ category -> addTranslation ( $ categoryTranslation ) ; $ this -> entityManager -> persist ( $ categoryTranslation ) ; return $ categoryTranslation ; }
Creates a new category translation for a given category and locale .
10,919
public function getMediaUrl ( Media $ media , $ dispositionType = null ) { $ url = $ media -> getUrl ( ) ; if ( ResponseHeaderBag :: DISPOSITION_INLINE === $ dispositionType ) { $ url .= ( false === strpos ( $ url , '?' ) ? '?inline=1' : '&inline=1' ) ; } elseif ( ResponseHeaderBag :: DISPOSITION_ATTACHMENT === $ dispositionType ) { $ url .= ( false === strpos ( $ url , '?' ) ? '?inline=0' : '&inline=0' ) ; } return $ url ; }
Get media url .
10,920
public function isValidLocale ( $ language , $ country ) { return ( $ this -> getLanguage ( ) === $ language && $ this -> getCountry ( ) === $ country ) || ( empty ( $ this -> getLanguage ( ) ) && empty ( $ this -> getCountry ( ) ) ) ; }
Checks if this URL handles the locale for the given language and country .
10,921
public function setTimestampsOnDocument ( HydrateEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ this -> supports ( $ document ) ) { return ; } $ accessor = $ event -> getAccessor ( ) ; $ node = $ event -> getNode ( ) ; $ locale = $ this -> documentInspector -> getOriginalLocale ( $ document ) ; $ encoding = $ this -> getPropertyEncoding ( $ document ) ; $ accessor -> set ( static :: CHANGED , $ node -> getPropertyValueWithDefault ( $ this -> propertyEncoder -> encode ( $ encoding , static :: CHANGED , $ locale ) , null ) ) ; $ accessor -> set ( static :: CREATED , $ node -> getPropertyValueWithDefault ( $ this -> propertyEncoder -> encode ( $ encoding , static :: CREATED , $ locale ) , null ) ) ; }
Sets the timestamps from the node to the document .
10,922
public function setTimestampsOnNodeForPersist ( PersistEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ this -> supports ( $ document ) ) { return ; } $ this -> setTimestampsOnNode ( $ document , $ event -> getNode ( ) , $ event -> getAccessor ( ) , $ this -> documentInspector -> getOriginalLocale ( $ document ) , new \ DateTime ( ) ) ; }
Sets the timestamps on the nodes for the persist operation .
10,923
public function setTimestampsOnNode ( LocalizedTimestampBehavior $ document , NodeInterface $ node , DocumentAccessor $ accessor , $ locale , $ timestamp = null ) { if ( ! $ document instanceof TimestampBehavior && ! $ locale ) { return ; } $ encoding = $ this -> getPropertyEncoding ( $ document ) ; $ createdPropertyName = $ this -> propertyEncoder -> encode ( $ encoding , static :: CREATED , $ locale ) ; if ( ! $ node -> hasProperty ( $ createdPropertyName ) ) { $ createdTimestamp = $ document -> getCreated ( ) ? : $ timestamp ; $ accessor -> set ( static :: CREATED , $ createdTimestamp ) ; $ node -> setProperty ( $ createdPropertyName , $ createdTimestamp ) ; } $ changedTimestamp = $ timestamp ? : $ document -> getChanged ( ) ; $ accessor -> set ( static :: CHANGED , $ changedTimestamp ) ; $ node -> setProperty ( $ this -> propertyEncoder -> encode ( $ encoding , static :: CHANGED , $ locale ) , $ changedTimestamp ) ; }
Set the timestamps on the node .
10,924
public function setChangedForRestore ( RestoreEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ this -> supports ( $ document ) ) { return ; } $ encoding = $ this -> getPropertyEncoding ( $ document ) ; $ event -> getNode ( ) -> setProperty ( $ this -> propertyEncoder -> encode ( $ encoding , static :: CHANGED , $ this -> documentInspector -> getOriginalLocale ( $ document ) ) , new \ DateTime ( ) ) ; }
Sets the changed timestamp when restoring a document .
10,925
public function createTranslatedProperty ( $ property , $ locale , StructureInterface $ structure = null ) { if ( $ property instanceof ItemMetadata ) { $ property = $ this -> createProperty ( $ property , $ structure ) ; } $ property = new TranslatedProperty ( $ property , $ locale , $ this -> namespaceRegistry -> getPrefix ( 'content_localized' ) ) ; return $ property ; }
Create a new translated property .
10,926
public function createProperty ( ItemMetadata $ property , StructureInterface $ structure = null ) { if ( $ property instanceof SectionMetadata ) { return $ this -> createSectionProperty ( $ property , $ structure ) ; } if ( $ property instanceof BlockMetadata ) { return $ this -> createBlockProperty ( $ property , $ structure ) ; } if ( null === $ property -> getType ( ) ) { throw new \ RuntimeException ( sprintf ( 'Property name "%s" has no type.' , $ property -> getName ( ) ) ) ; } $ parameters = $ this -> convertArrayToParameters ( $ property -> getParameters ( ) ) ; $ propertyBridge = new LegacyProperty ( $ property -> getName ( ) , [ 'title' => $ property -> getTitles ( ) , 'info_text' => $ property -> getDescriptions ( ) , 'placeholder' => $ property -> getPlaceholders ( ) , ] , $ property -> getType ( ) , $ property -> isRequired ( ) , $ property -> isLocalized ( ) , $ property -> getMaxOccurs ( ) , $ property -> getMinOccurs ( ) , $ parameters , [ ] , $ property -> getColSpan ( ) ) ; foreach ( $ property -> getTags ( ) as $ tag ) { $ propertyBridge -> addTag ( new PropertyTag ( $ tag [ 'name' ] , $ tag [ 'priority' ] , $ tag [ 'attributes' ] ) ) ; } $ propertyBridge -> setStructure ( $ structure ) ; return $ propertyBridge ; }
Create a new property .
10,927
public function onPostSerialize ( ObjectEvent $ event ) { $ document = $ event -> getObject ( ) ; if ( ! $ document instanceof ChildrenBehavior || ! $ this -> documentRegistry -> hasDocument ( $ document ) ) { return ; } $ visitor = $ event -> getVisitor ( ) ; $ visitor -> addData ( 'hasSub' , $ this -> documentInspector -> hasChildren ( $ document ) ) ; }
Adds a flag to indicate if the document has children .
10,928
protected function getParser ( $ format ) { if ( ! isset ( $ this -> formatFilePaths [ $ format ] ) ) { throw new FormatImporterNotFoundException ( $ format ) ; } return $ this -> formatFilePaths [ $ format ] ; }
Returns the correct parser like XLIFF1 . 2 .
10,929
protected function importProperty ( PropertyInterface $ property , NodeInterface $ node , StructureInterface $ structure , $ value , $ webspaceKey , $ locale , $ format ) { $ contentType = $ property -> getContentTypeName ( ) ; if ( ! $ this -> importManager -> hasImport ( $ contentType , $ format ) ) { return ; } $ translateProperty = $ this -> legacyPropertyFactory -> createTranslatedProperty ( $ property , $ locale , $ structure ) ; $ this -> importManager -> import ( $ contentType , $ node , $ translateProperty , $ value , null , $ webspaceKey , $ locale ) ; }
Prepare document - property and import them .
10,930
protected function decorateResourceItems ( array $ data , $ locale ) { return array_map ( function ( $ item ) { $ itemData = $ this -> serializer -> serialize ( $ item , 'array' , $ this -> getSerializationContext ( ) ) ; $ id = $ this -> getIdForItem ( $ item ) ; if ( $ this -> referenceStore ) { $ this -> referenceStore -> add ( $ id ) ; } return new ArrayAccessItem ( $ id , $ itemData , $ item ) ; } , $ data ) ; }
Decorates result as resource item .
10,931
public function addUrl ( \ Sulu \ Bundle \ ContactBundle \ Entity \ Url $ urls ) { $ this -> urls [ ] = $ urls ; return $ this ; }
Add urls .
10,932
public function removeUrl ( \ Sulu \ Bundle \ ContactBundle \ Entity \ Url $ urls ) { $ this -> urls -> removeElement ( $ urls ) ; }
Remove urls .
10,933
public function indexDocumentAfterRemoveDraft ( RemoveDraftEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( $ document instanceof WorkflowStageBehavior ) { $ document -> setWorkflowStage ( WorkflowStage :: TEST ) ; } $ this -> indexDocument ( $ document ) ; if ( $ document instanceof WorkflowStageBehavior ) { $ document -> setWorkflowStage ( WorkflowStage :: PUBLISHED ) ; } }
Indexes a document after its draft have been removed .
10,934
private function indexDocument ( $ document ) { if ( ! $ document instanceof StructureBehavior ) { return ; } if ( $ document instanceof SecurityBehavior && ! empty ( $ document -> getPermissions ( ) ) ) { return ; } $ this -> searchManager -> index ( $ document ) ; }
Index document in search implementation depending on the publish state .
10,935
public function deindexRemovedDocument ( RemoveEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ document instanceof StructureBehavior ) { return ; } if ( ! $ document instanceof WorkflowStageBehavior ) { $ this -> searchManager -> deindex ( $ document ) ; } else { $ workflowStage = $ document -> getWorkflowStage ( ) ; foreach ( WorkflowStage :: $ stages as $ stage ) { $ document -> setWorkflowStage ( $ stage ) ; $ this -> searchManager -> deindex ( $ document ) ; } $ document -> setWorkflowStage ( $ workflowStage ) ; } }
Schedules a document to be deindexed .
10,936
public function deindexUnpublishedDocument ( UnpublishEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ document instanceof StructureBehavior ) { return ; } $ this -> searchManager -> deindex ( $ document ) ; }
Deindexes the document from the search index for the website .
10,937
public function redirectWebspaceAction ( Request $ request ) { @ trigger_error ( __METHOD__ . '() is deprecated since version 1.6 and will be removed in 2.0. Replaced by ExceptionListener::redirectPartialMatch.' , E_USER_DEPRECATED ) ; $ url = $ this -> resolveRedirectUrl ( $ request -> get ( 'redirect' ) , $ request -> getUri ( ) , $ request -> get ( '_sulu' ) -> getAttribute ( 'resourceLocatorPrefix' ) ) ; return new RedirectResponse ( $ url , 301 , [ 'Cache-Control' => 'private' ] ) ; }
Creates a redirect for configured webspaces .
10,938
public function redirectToRouteAction ( Request $ request , $ route , $ permanent = false ) { if ( '' === $ route ) { throw new HttpException ( $ permanent ? 410 : 404 ) ; } $ attributes = array_merge ( $ request -> attributes -> get ( '_route_params' ) , $ request -> query -> all ( ) ) ; unset ( $ attributes [ 'route' ] , $ attributes [ 'permanent' ] ) ; return new RedirectResponse ( $ this -> container -> get ( 'router' ) -> generate ( $ route , $ attributes , UrlGeneratorInterface :: ABSOLUTE_URL ) , $ permanent ? 301 : 302 , [ 'Cache-Control' => 'private' ] ) ; }
Create a redirect response which uses a route to generate redirect .
10,939
protected function setBreadcrumbToCollection ( Collection $ collection , $ locale , $ breadcrumbEntities ) { $ breadcrumbApiEntities = [ ] ; foreach ( $ breadcrumbEntities as $ entity ) { $ breadcrumbApiEntities [ ] = $ this -> getApiEntity ( $ entity , $ locale ) ; } $ collection -> setBreadcrumb ( $ breadcrumbApiEntities ) ; return $ collection ; }
Sets the given breadcrumb entities as breadcrum on the given collection .
10,940
protected function getApiEntity ( CollectionInterface $ entity , $ locale , $ entities = null , $ breadcrumbEntities = null ) { $ apiEntity = new Collection ( $ entity , $ locale ) ; $ children = null ; if ( null !== $ entities ) { $ children = [ ] ; foreach ( $ entities as $ possibleChild ) { if ( null !== ( $ parent = $ possibleChild -> getParent ( ) ) && $ parent -> getId ( ) === $ entity -> getId ( ) ) { $ children [ ] = $ this -> getApiEntity ( $ possibleChild , $ locale , $ entities ) ; } } } $ apiEntity -> setChildren ( $ children ) ; if ( null !== $ entity -> getParent ( ) ) { $ apiEntity -> setParent ( $ this -> getApiEntity ( $ entity -> getParent ( ) , $ locale ) ) ; } if ( null !== $ breadcrumbEntities ) { $ this -> setBreadcrumbToCollection ( $ apiEntity , $ locale , $ breadcrumbEntities ) ; } if ( $ entity && $ entity -> getId ( ) ) { $ apiEntity -> setMediaCount ( $ this -> collectionRepository -> countMedia ( $ entity ) ) ; $ apiEntity -> setSubCollectionCount ( $ this -> collectionRepository -> countSubCollections ( $ entity ) ) ; } return $ this -> addPreview ( $ apiEntity ) ; }
Prepare an api entity .
10,941
protected function getCurrentUser ( ) { if ( $ this -> tokenStorage && ( $ token = $ this -> tokenStorage -> getToken ( ) ) ) { $ user = $ token -> getUser ( ) ; if ( $ user instanceof UserInterface ) { return $ user ; } } return ; }
Returns the current user from the token storage .
10,942
public static function getValueFromXPath ( $ path , \ DOMXPath $ xpath , \ DomNode $ context = null , $ default = null ) { $ result = $ xpath -> query ( $ path , $ context ) ; if ( 0 === $ result -> length ) { return $ default ; } $ item = $ result -> item ( 0 ) ; if ( null === $ item ) { return $ default ; } return $ item -> nodeValue ; }
Returns value of path .
10,943
public static function getBooleanValueFromXPath ( $ path , \ DOMXPath $ xpath , \ DomNode $ context = null , $ default = null ) { $ value = self :: getValueFromXPath ( $ path , $ xpath , $ context , $ default ) ; if ( null === $ value ) { return ; } return 'true' === $ value || true === $ value ; }
Returns boolean value of path .
10,944
public function renderSeoTags ( \ Twig_Environment $ twig , array $ seoExtension , array $ content , array $ urls , $ shadowBaseLocale ) { $ template = 'SuluWebsiteBundle:Extension:seo.html.twig' ; @ trigger_error ( sprintf ( 'This twig extension is deprecated and should not be used anymore, include the "%s".' , $ template ) ) ; $ defaultLocale = null ; $ portal = $ this -> requestAnalyzer -> getPortal ( ) ; if ( $ portal ) { $ defaultLocale = $ portal -> getXDefaultLocalization ( ) -> getLocale ( ) ; } return $ twig -> render ( $ template , [ 'seo' => $ seoExtension , 'content' => $ content , 'urls' => $ urls , 'defaultLocale' => $ defaultLocale , 'shadowBaseLocale' => $ shadowBaseLocale , ] ) ; }
Renders the correct title of the current page . The correct title is either the title provided by the SEO extension or the title of the content if the SEO extension does not provide one .
10,945
private function getHeightWidth ( $ x , $ y , $ retina , $ forceRatio , $ size , $ mode ) { $ newWidth = $ x ; $ newHeight = $ y ; if ( $ retina ) { $ newWidth = $ x * 2 ; $ newHeight = $ y * 2 ; } if ( ! $ newHeight ) { $ newHeight = $ size -> getHeight ( ) / $ size -> getWidth ( ) * $ newWidth ; } if ( ! $ newWidth ) { $ newWidth = $ size -> getWidth ( ) / $ size -> getHeight ( ) * $ newHeight ; } if ( ImageInterface :: THUMBNAIL_OUTBOUND === $ mode && $ forceRatio ) { if ( $ newWidth > $ size -> getWidth ( ) ) { list ( $ newHeight , $ newWidth ) = $ this -> getSizeInSameRatio ( $ newHeight , $ newWidth , $ size -> getWidth ( ) ) ; } if ( $ newHeight > $ size -> getHeight ( ) ) { list ( $ newWidth , $ newHeight ) = $ this -> getSizeInSameRatio ( $ newWidth , $ newHeight , $ size -> getHeight ( ) ) ; } } return [ $ newWidth , $ newHeight ] ; }
Gets the height and width of the resulting image according to the given parameters .
10,946
private function matchCustomUrl ( $ url , PortalInformation $ portalInformation , Request $ request ) { $ webspace = $ portalInformation -> getWebspace ( ) ; $ routeDocument = $ this -> customUrlManager -> findRouteByUrl ( rawurldecode ( $ url ) , $ webspace -> getKey ( ) ) ; if ( ! $ routeDocument ) { return [ ] ; } elseif ( $ routeDocument -> isHistory ( ) ) { return [ 'customUrlRoute' => $ routeDocument ] ; } $ customUrlDocument = $ this -> customUrlManager -> findByUrl ( rawurldecode ( $ url ) , $ webspace -> getKey ( ) , $ routeDocument -> getTargetDocument ( ) -> getTargetLocale ( ) ) ; if ( null === $ customUrlDocument || false === $ customUrlDocument -> isPublished ( ) || null === $ customUrlDocument -> getTargetDocument ( ) || WorkflowStage :: PUBLISHED !== $ customUrlDocument -> getTargetDocument ( ) -> getWorkflowStage ( ) ) { return [ 'customUrlRoute' => $ routeDocument , 'customUrl' => $ customUrlDocument ] ; } $ localization = Localization :: createFromString ( $ customUrlDocument -> getTargetLocale ( ) ) ; $ portalInformations = $ this -> webspaceManager -> findPortalInformationsByWebspaceKeyAndLocale ( $ portalInformation -> getWebspace ( ) -> getKey ( ) , $ localization -> getLocale ( ) , $ this -> environment ) ; if ( 0 === count ( $ portalInformations ) ) { return [ 'customUrlRoute' => $ routeDocument , 'customUrl' => $ customUrlDocument ] ; } return [ 'portalInformation' => $ portalInformation , 'localization' => $ localization , 'locale' => $ localization -> getLocale ( ) , 'customUrlRoute' => $ routeDocument , 'customUrl' => $ customUrlDocument , 'urlExpression' => $ this -> generator -> generate ( $ customUrlDocument -> getBaseDomain ( ) , $ customUrlDocument -> getDomainParts ( ) ) , ] ; }
Matches given url to portal - information .
10,947
private function checkMimeTypeSupported ( $ mimeType ) { foreach ( $ this -> supportedMimeTypes as $ supportedMimeType ) { if ( fnmatch ( $ supportedMimeType , $ mimeType ) ) { return true ; } } return false ; }
Returns true if the given mime type is supported otherwise false .
10,948
public function setContact ( \ Sulu \ Bundle \ ContactBundle \ Entity \ ContactInterface $ contact ) { $ this -> contact = $ contact ; return $ this ; }
Set contact .
10,949
public function setEmailType ( \ Sulu \ Bundle \ ContactBundle \ Entity \ EmailType $ emailType ) { $ this -> emailType = $ emailType ; return $ this ; }
Set emailType .
10,950
public function handleDefaultLocale ( HydrateEvent $ event ) { if ( null === $ event -> getLocale ( ) ) { $ event -> setLocale ( $ this -> documentRegistry -> getDefaultLocale ( ) ) ; } }
Set the default locale for the hydration request .
10,951
public function handleDocumentFromRegistry ( HydrateEvent $ event ) { if ( $ event -> hasDocument ( ) ) { return ; } $ node = $ event -> getNode ( ) ; if ( ! $ this -> documentRegistry -> hasNode ( $ node , $ event -> getLocale ( ) ) ) { return ; } $ document = $ this -> documentRegistry -> getDocumentForNode ( $ node , $ event -> getLocale ( ) ) ; $ event -> setDocument ( $ document ) ; $ options = $ event -> getOptions ( ) ; if ( isset ( $ options [ 'rehydrate' ] ) && false === $ options [ 'rehydrate' ] ) { $ event -> stopPropagation ( ) ; } }
If there is already a document for the node registered use that .
10,952
public function handleStopPropagationAndResetLocale ( HydrateEvent $ event ) { if ( ! $ event -> hasDocument ( ) ) { return ; } $ locale = $ event -> getLocale ( ) ; $ document = $ event -> getDocument ( ) ; $ options = $ event -> getOptions ( ) ; $ originalLocale = $ this -> documentRegistry -> getOriginalLocaleForDocument ( $ document ) ; if ( ( ! isset ( $ options [ 'rehydrate' ] ) || false === $ options [ 'rehydrate' ] ) && ( true === $ this -> documentRegistry -> isHydrated ( $ document ) && $ originalLocale === $ locale ) ) { $ event -> stopPropagation ( ) ; } }
Stop propagation if the document is already loaded in the requested locale .
10,953
public function handleNodeFromRegistry ( $ event ) { if ( $ event -> hasNode ( ) ) { return ; } $ document = $ event -> getDocument ( ) ; if ( ! $ this -> documentRegistry -> hasDocument ( $ document ) ) { return ; } $ node = $ this -> documentRegistry -> getNodeForDocument ( $ document ) ; $ event -> setNode ( $ node ) ; }
If the node for the persisted document is in the registry .
10,954
public function handleRemove ( RemoveEvent $ event ) { $ document = $ event -> getDocument ( ) ; $ this -> documentRegistry -> deregisterDocument ( $ document ) ; }
Deregister removed documents .
10,955
private function handleRegister ( AbstractMappingEvent $ event ) { $ node = $ event -> getNode ( ) ; $ locale = $ event -> getLocale ( ) ; if ( ! $ this -> documentRegistry -> hasNode ( $ node , $ locale ) ) { $ this -> documentRegistry -> registerDocument ( $ event -> getDocument ( ) , $ node , $ locale ) ; } }
Register the document .
10,956
public function doSetValue ( $ value ) { $ items = $ value ; if ( $ value instanceof PropertyValue ) { $ items = $ value -> getValue ( ) ; } if ( null == $ items ) { return ; } if ( array_keys ( $ items ) !== range ( 0 , count ( $ items ) - 1 ) ) { $ items = [ $ items ] ; } $ this -> properties = [ ] ; for ( $ i = 0 ; $ i < count ( $ items ) ; ++ $ i ) { $ item = $ items [ $ i ] ; $ type = $ this -> initProperties ( $ i , $ item [ 'type' ] ) ; foreach ( $ type -> getChildProperties ( ) as $ subProperty ) { if ( ! isset ( $ item [ $ subProperty -> getName ( ) ] ) ) { continue ; } $ subName = $ subProperty -> getName ( ) ; $ subValue = $ item [ $ subName ] ; if ( $ subValue instanceof PropertyValue ) { $ subValueProperty = new PropertyValue ( $ subName , $ subValue ) ; $ subProperty -> setPropertyValue ( $ subValueProperty ) ; $ item [ $ subName ] = $ subValueProperty ; } else { $ subProperty -> setValue ( $ subValue ) ; } } $ items [ $ i ] = $ item ; } if ( $ value instanceof PropertyValue ) { $ value -> setValue ( $ items ) ; } }
Sub properties need to be referenced to the PropertyValue so that the real property is updated .
10,957
public function getValue ( ) { if ( count ( $ this -> properties ) < $ this -> getMinOccurs ( ) ) { for ( $ i = count ( $ this -> properties ) ; $ i < $ this -> getMinOccurs ( ) ; ++ $ i ) { $ this -> initProperties ( $ i , $ this -> getDefaultTypeName ( ) ) ; } } $ data = [ ] ; foreach ( $ this -> properties as $ type ) { $ result = [ 'type' => $ type -> getName ( ) ] ; foreach ( $ type -> getChildProperties ( ) as $ property ) { $ result [ $ property -> getName ( ) ] = $ property -> getValue ( ) ; } $ data [ ] = $ result ; } return $ data ; }
get value of sub properties .
10,958
private function defineRepositories ( array $ objects , ContainerBuilder $ container ) { foreach ( $ objects as $ object => $ services ) { if ( array_key_exists ( 'model' , $ services ) ) { $ repositoryDefinition = $ this -> getRepositoryDefinition ( $ object , $ services , $ container ) ; $ container -> setDefinition ( $ this -> getContainerKey ( 'repository' , $ object ) , $ repositoryDefinition ) -> setPublic ( true ) ; } } }
Define repositories .
10,959
private function getRepositoryDefinition ( $ object , array $ services , ContainerBuilder $ container ) { $ repositoryKey = $ this -> getContainerKey ( 'repository' , $ object , '.class' ) ; $ repositoryClass = 'Sulu\Component\Persistence\Repository\ORM\EntityRepository' ; if ( $ container -> hasParameter ( $ repositoryKey ) ) { $ repositoryClass = $ container -> getParameter ( $ repositoryKey ) ; } if ( isset ( $ services [ 'repository' ] ) ) { $ repositoryClass = $ services [ 'repository' ] ; } $ definition = new Definition ( $ repositoryClass ) ; $ definition -> setArguments ( [ new Reference ( $ this -> getEntityManagerServiceKey ( ) ) , $ this -> getClassMetadataDefinition ( $ services [ 'model' ] ) , ] ) ; return $ definition ; }
Get the repository service definition .
10,960
private function remapObjectParameters ( array $ objects , ContainerBuilder $ container ) { foreach ( $ objects as $ object => $ services ) { foreach ( $ services as $ service => $ class ) { $ container -> setParameter ( sprintf ( 'sulu.%s.%s.class' , $ service , $ object ) , $ class ) ; } } }
Remap object parameters .
10,961
public static function createFromString ( $ locale , $ format = self :: UNDERSCORE ) { $ delimiter = '-' ; if ( in_array ( $ format , [ self :: UNDERSCORE , self :: LCID ] ) ) { $ delimiter = '_' ; } $ parts = explode ( $ delimiter , $ locale ) ; $ localization = new self ( ) ; $ localization -> setLanguage ( strtolower ( $ parts [ 0 ] ) ) ; if ( count ( $ parts ) > 1 ) { $ localization -> setCountry ( strtolower ( $ parts [ 1 ] ) ) ; } return $ localization ; }
Create an instance of localization for given locale .
10,962
public function getLocalization ( $ delimiter = '_' ) { @ trigger_error ( __METHOD__ . '() is deprecated since version 1.2 and will be removed in 2.0. Use getLocale() instead.' , E_USER_DEPRECATED ) ; $ localization = $ this -> getLanguage ( ) ; if ( null != $ this -> getCountry ( ) ) { $ localization .= $ delimiter . $ this -> getCountry ( ) ; } return $ localization ; }
Returns the localization code which is a combination of the language and the country .
10,963
public function getLocale ( $ format = self :: UNDERSCORE ) { $ localization = strtolower ( $ this -> getLanguage ( ) ) ; if ( null != $ this -> getCountry ( ) ) { $ country = strtolower ( $ this -> getCountry ( ) ) ; $ delimiter = '-' ; switch ( $ format ) { case self :: UNDERSCORE : $ delimiter = '_' ; break ; case self :: ISO6391 : $ country = strtoupper ( $ country ) ; break ; case self :: LCID : $ delimiter = '_' ; $ country = strtoupper ( $ country ) ; break ; } $ localization .= $ delimiter . $ country ; } return $ localization ; }
Returns the localization code which is a combination of the language and the country in a specific format .
10,964
private function validate ( $ content , $ locale ) { $ validation = $ this -> markupParser -> validate ( $ content , $ locale ) ; $ regex = sprintf ( self :: INVALID_REGEX , $ this -> markupNamespace , $ this -> markupNamespace ) ; foreach ( $ validation as $ tag => $ state ) { if ( false === strpos ( $ tag , 'sulu-validation-state="' . $ state . '"' ) ) { $ newTag = preg_replace ( $ regex , '$1 sulu-validation-state="' . $ state . '"$2' , $ tag ) ; $ content = str_replace ( $ tag , $ newTag , $ content ) ; } } return $ content ; }
Returns validated content .
10,965
public function convert ( $ data ) { if ( empty ( $ data ) ) { return [ ] ; } $ map = [ ] ; $ minDepth = 99 ; foreach ( $ data as $ item ) { $ path = rtrim ( '/root' . $ item [ 'path' ] , '/' ) ; $ map [ $ path ] = $ item ; $ parts = explode ( '/' , $ path ) ; $ parts = array_filter ( $ parts ) ; $ depth = count ( $ parts ) ; if ( $ minDepth > $ depth ) { $ minDepth = $ depth ; } } uksort ( $ map , function ( $ a , $ b ) use ( $ map ) { $ depthDifference = substr_count ( $ a , '/' ) - substr_count ( $ b , '/' ) ; if ( $ depthDifference > 0 ) { return 1 ; } elseif ( $ depthDifference < 0 ) { return - 1 ; } else { $ aPosition = array_search ( $ a , array_keys ( $ map ) ) ; $ bPosition = array_search ( $ b , array_keys ( $ map ) ) ; return ( $ aPosition < $ bPosition ) ? - 1 : 1 ; } } ) ; $ tree = $ this -> explodeTree ( $ map , '/' ) ; for ( $ i = 0 ; $ i < $ minDepth - 1 ; ++ $ i ) { $ tree [ 'children' ] = array_values ( $ tree [ 'children' ] ) ; if ( ! array_key_exists ( 'children' , $ tree ) || ! array_key_exists ( 0 , $ tree [ 'children' ] ) ) { return [ ] ; } $ tree = $ tree [ 'children' ] [ 0 ] ; } $ tree = $ this -> toArray ( $ tree ) ; return $ tree [ 'children' ] ; }
generate a tree of the given data with the path property .
10,966
private function explodeTree ( $ array , $ delimiter = '_' , $ baseval = false ) { if ( ! is_array ( $ array ) ) { return false ; } $ splitRE = '/' . preg_quote ( $ delimiter , '/' ) . '/' ; $ returnArr = [ ] ; foreach ( $ array as $ key => $ val ) { $ parts = preg_split ( $ splitRE , $ key , - 1 , PREG_SPLIT_NO_EMPTY ) ; $ leafPart = array_pop ( $ parts ) ; $ parentArr = & $ returnArr ; foreach ( $ parts as $ part ) { if ( isset ( $ parentArr [ 'children' ] [ $ part ] ) ) { if ( ! is_array ( $ parentArr [ 'children' ] [ $ part ] ) ) { if ( $ baseval ) { $ parentArr [ 'children' ] [ $ part ] = [ '__base_val' => $ parentArr [ $ part ] ] ; } else { $ parentArr [ 'children' ] [ $ part ] = [ ] ; } } $ parentArr = & $ parentArr [ 'children' ] [ $ part ] ; } else { $ parentArr [ 'children' ] [ $ part ] = [ ] ; $ parentArr = & $ parentArr [ 'children' ] [ $ part ] ; } } if ( empty ( $ parentArr [ 'children' ] [ $ leafPart ] ) ) { $ parentArr [ 'children' ] [ $ leafPart ] = $ val ; } elseif ( $ baseval && is_array ( $ parentArr [ 'children' ] [ $ leafPart ] ) ) { $ parentArr [ 'children' ] [ $ leafPart ] [ '__base_val' ] = $ val ; } else { $ parentArr [ 'children' ] [ $ leafPart ] = array_merge ( $ val , $ parentArr [ 'children' ] [ $ leafPart ] ) ; } } return $ returnArr ; }
Explode any single - dimensional array into a full blown tree structure based on the delimiters found in it s keys .
10,967
public function handleRemove ( RemoveEvent $ event ) { $ document = $ event -> getDocument ( ) ; $ node = $ this -> documentRegistry -> getNodeForDocument ( $ document ) ; $ node -> remove ( ) ; }
Remove the given documents node from PHPCR session and optionally remove any references to the node .
10,968
protected function clearDestinationWebspace ( ) { $ homeDocument = $ this -> documentManager -> find ( $ this -> sessionManager -> getContentPath ( $ this -> webspaceKeyDestination ) ) ; foreach ( $ homeDocument -> getChildren ( ) as $ child ) { $ this -> output -> writeln ( '<info>Processing: </info>' . $ child -> getPath ( ) ) ; $ this -> documentManager -> remove ( $ child ) ; $ this -> documentManager -> flush ( ) ; } }
Removes all pages from given webspace .
10,969
protected function updateBlocksStructure ( array & $ structureArray , BlockMetadata $ property , $ localeSource , $ localeDestination ) { if ( ! array_key_exists ( $ property -> getName ( ) , $ structureArray ) || ! $ structureArray [ $ property -> getName ( ) ] ) { return ; } foreach ( $ structureArray [ $ property -> getName ( ) ] as & $ structure ) { $ component = $ property -> getComponentByName ( $ structure [ 'type' ] ) ; foreach ( $ component -> getChildren ( ) as $ child ) { if ( $ structure [ $ child -> getName ( ) ] ) { $ this -> processContentType ( $ child , $ structure , $ localeSource , $ localeDestination ) ; } } } }
Process content type block .
10,970
protected function updateSmartContentStructure ( array & $ structureArray , PropertyMetadata $ property , $ localeSource , $ localeDestination ) { foreach ( $ property -> getParameters ( ) as $ parameter ) { if ( ! array_key_exists ( $ property -> getName ( ) , $ structureArray ) ) { continue ; } if ( 'provider' !== $ parameter [ 'name' ] || 'content' !== $ parameter [ 'value' ] ) { continue ; } if ( ! array_key_exists ( 'dataSource' , $ structureArray [ $ property -> getName ( ) ] ) ) { continue ; } $ targetDocumentDestination = $ this -> getTargetDocumentDestination ( $ structureArray [ $ property -> getName ( ) ] [ 'dataSource' ] , $ localeSource , $ localeDestination ) ; if ( ! $ targetDocumentDestination ) { continue ; } $ structureArray [ $ property -> getName ( ) ] [ 'dataSource' ] = $ targetDocumentDestination -> getUuid ( ) ; } }
Updates the smart content structure when the property dataSource is set and the target is in the same webspace .
10,971
protected function updatePageSelection ( array & $ structureArray , PropertyMetadata $ property , $ localeSource , $ localeDestination ) { if ( ! array_key_exists ( $ property -> getName ( ) , $ structureArray ) || ! $ structureArray [ $ property -> getName ( ) ] ) { return ; } foreach ( $ structureArray [ $ property -> getName ( ) ] as $ key => $ value ) { $ targetDocumentDestination = $ this -> getTargetDocumentDestination ( $ value , $ localeSource , $ localeDestination ) ; if ( ! $ targetDocumentDestination ) { continue ; } $ structureArray [ $ property -> getName ( ) ] [ $ key ] = $ targetDocumentDestination -> getUuid ( ) ; } }
Updates references in structure for content type page_selection .
10,972
protected function updateSinglePageSelection ( array & $ structureArray , PropertyMetadata $ property , $ localeSource , $ localeDestination ) { if ( ! array_key_exists ( $ property -> getName ( ) , $ structureArray ) || ! $ structureArray [ $ property -> getName ( ) ] ) { return ; } $ targetDocumentDestination = $ this -> getTargetDocumentDestination ( $ structureArray [ $ property -> getName ( ) ] , $ localeSource , $ localeDestination ) ; if ( ! $ targetDocumentDestination ) { return ; } $ structureArray [ $ property -> getName ( ) ] = $ targetDocumentDestination -> getUuid ( ) ; }
Updates references in structure for content type single_page_selection .
10,973
public function getAction ( $ id ) { $ view = $ this -> responseGetById ( $ id , function ( $ id ) { return $ this -> getDoctrine ( ) -> getRepository ( self :: $ entityName ) -> find ( $ id ) ; } ) ; return $ this -> handleView ( $ view ) ; }
Shows a single position for the given id .
10,974
public function cgetAction ( ) { $ list = new CollectionRepresentation ( $ this -> getDoctrine ( ) -> getRepository ( self :: $ entityName ) -> findBy ( [ ] , [ 'position' => 'ASC' ] ) , self :: $ entityKey ) ; $ view = $ this -> view ( $ list , 200 ) ; return $ this -> handleView ( $ view ) ; }
lists all positions optional parameter flat calls listAction .
10,975
public function postAction ( Request $ request ) { $ name = $ request -> get ( 'position' ) ; try { if ( null == $ name ) { throw new RestException ( 'There is no position-name for the given name' ) ; } $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ position = new Position ( ) ; $ position -> setPosition ( $ name ) ; $ em -> persist ( $ position ) ; $ em -> flush ( ) ; $ view = $ this -> view ( $ position , 200 ) ; } catch ( EntityNotFoundException $ enfe ) { $ view = $ this -> view ( $ enfe -> toArray ( ) , 404 ) ; } catch ( RestException $ re ) { $ view = $ this -> view ( $ re -> toArray ( ) , 400 ) ; } return $ this -> handleView ( $ view ) ; }
Creates a new position .
10,976
public function clear ( $ cache = null ) { if ( null !== $ cache ) { if ( ! array_key_exists ( $ cache , $ this -> caches ) ) { throw new CacheNotFoundException ( $ cache ) ; } $ this -> caches [ $ cache ] -> clear ( ) ; } else { foreach ( $ this -> caches as $ cache ) { $ cache -> clear ( ) ; } } }
Clear all or the given cache .
10,977
public function getConditions ( ) { $ conditions = $ this -> entity -> getConditions ( ) ; $ result = [ ] ; if ( $ conditions ) { foreach ( $ conditions as $ condition ) { $ result [ ] = new Condition ( $ condition , $ this -> locale ) ; } return $ result ; } return ; }
Get conditions .
10,978
public function getSelect ( ) { $ concat = null ; foreach ( $ this -> fieldDescriptors as $ fieldDescriptor ) { if ( null == $ concat ) { $ concat = $ fieldDescriptor -> getSelect ( ) ; } else { $ concat = 'CONCAT(' . $ concat . ', CONCAT(\'' . $ this -> glue . '\', ' . $ fieldDescriptor -> getSelect ( ) . '))' ; } } return $ concat ; }
Returns the select statement for this field without the alias .
10,979
public function getJoins ( ) { $ joins = [ ] ; foreach ( $ this -> fieldDescriptors as $ fieldDescriptor ) { $ joins = array_merge ( $ joins , $ fieldDescriptor -> getJoins ( ) ) ; } return $ joins ; }
Returns all the joins required for this field .
10,980
public function clearAction ( ) { if ( ! $ this -> checkLivePermissionForAllWebspaces ( ) ) { return new JsonResponse ( null , 403 ) ; } $ this -> get ( 'sulu_website.http_cache.clearer' ) -> clear ( ) ; return new JsonResponse ( null , 204 ) ; }
Clear the whole http_cache for website .
10,981
private function checkLivePermissionForAllWebspaces ( ) { foreach ( $ this -> get ( 'sulu_core.webspace.webspace_manager' ) -> getWebspaceCollection ( ) as $ webspace ) { $ context = PageAdmin :: SECURITY_CONTEXT_PREFIX . $ webspace -> getKey ( ) ; if ( ! $ this -> get ( 'sulu_security.security_checker' ) -> hasPermission ( $ context , PermissionTypes :: LIVE ) ) { return false ; } } return true ; }
Check the permissions for all webspaces . Returns true if the user has live permission in all webspaces .
10,982
public function addDomain ( Domain $ domain ) { if ( $ this -> domains -> contains ( $ domain ) ) { return $ this ; } $ this -> domains [ ] = $ domain ; return $ this ; }
Add domain .
10,983
public function getDomains ( ) { if ( 0 === count ( $ this -> domains ) ) { return null ; } return $ this -> domains -> map ( function ( Domain $ domain ) { return $ domain -> getUrl ( ) ; } ) ; }
Get domains .
10,984
public function handleHydrate ( AbstractMappingEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ document instanceof ShadowLocaleBehavior || ! $ event -> getOption ( 'load_shadow_content' ) ) { return ; } $ node = $ event -> getNode ( ) ; $ locale = $ this -> inspector -> getOriginalLocale ( $ document ) ; $ shadowLocaleEnabled = $ this -> getShadowLocaleEnabled ( $ node , $ locale ) ; $ document -> setShadowLocaleEnabled ( $ shadowLocaleEnabled ) ; if ( ! $ shadowLocaleEnabled ) { return ; } $ shadowLocale = $ this -> getShadowLocale ( $ node , $ locale ) ; $ document -> setShadowLocale ( $ shadowLocale ) ; $ event -> setLocale ( $ shadowLocale ) ; $ document -> setLocale ( $ shadowLocale ) ; }
Update the locale to the shadow locale if it is enabled .
10,985
public function handlePersistUpdateUrl ( PersistEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ document instanceof ShadowLocaleBehavior ) { return ; } if ( ! $ document -> isShadowLocaleEnabled ( ) ) { return ; } $ node = $ event -> getNode ( ) ; $ structure = $ this -> inspector -> getStructureMetadata ( $ document ) ; if ( false === $ structure -> hasPropertyWithTagName ( 'sulu.rlp' ) ) { return ; } $ locatorProperty = $ structure -> getPropertyByTagName ( 'sulu.rlp' ) ; if ( $ node -> getPropertyValueWithDefault ( $ this -> encoder -> localizedSystemName ( $ locatorProperty -> getName ( ) , $ document -> getLocale ( ) ) , null ) ) { return ; } $ shadowLocator = $ node -> getPropertyValueWithDefault ( $ this -> encoder -> localizedSystemName ( $ locatorProperty -> getName ( ) , $ document -> getShadowLocale ( ) ) , null ) ; if ( ! $ shadowLocator ) { return ; } $ event -> getAccessor ( ) -> set ( 'resourceSegment' , $ shadowLocator ) ; }
If this is a shadow document update the URL to that of the shadowed document .
10,986
public function getContentPath ( PathBehavior $ document ) { $ path = $ this -> getPath ( $ document ) ; $ webspaceKey = $ this -> getWebspace ( $ document ) ; return str_replace ( sprintf ( '/%s/%s/%s' , $ this -> pathSegmentRegistry -> getPathSegment ( 'base' ) , $ webspaceKey , $ this -> pathSegmentRegistry -> getPathSegment ( 'content' ) ) , '' , $ path ) ; }
Return the path of the document in relation to the content root .
10,987
public function getStructureMetadata ( StructureBehavior $ document ) { try { return $ this -> structureFactory -> getStructureMetadata ( $ this -> getMetadata ( $ document ) -> getAlias ( ) , $ document -> getStructureType ( ) ) ; } catch ( StructureTypeNotFoundException $ exception ) { return ; } }
Return the structure for the given StructureBehavior implementing document .
10,988
public function getLocalizationState ( $ document ) { if ( $ document instanceof ShadowLocaleBehavior ) { if ( true === $ document -> isShadowLocaleEnabled ( ) ) { return LocalizationState :: SHADOW ; } } $ originalLocale = $ document -> getOriginalLocale ( ) ; $ currentLocale = $ document -> getLocale ( ) ; if ( $ originalLocale === $ currentLocale ) { return LocalizationState :: LOCALIZED ; } return LocalizationState :: GHOST ; }
Return the localization state of the node .
10,989
public function getLocale ( $ document ) { if ( $ document instanceof LocaleBehavior ) { return $ document -> getLocale ( ) ; } if ( $ this -> documentRegistry -> hasDocument ( $ document ) ) { return $ this -> documentRegistry -> getLocaleForDocument ( $ document ) ; } return ; }
Return the locale for the given document or null if the document is not managed .
10,990
public function getLocales ( $ document ) { $ locales = [ ] ; $ node = $ this -> getNode ( $ document ) ; $ prefix = $ this -> namespaceRegistry -> getPrefix ( 'system_localized' ) ; foreach ( $ node -> getProperties ( ) as $ property ) { preg_match ( sprintf ( '/^%s:([a-zA-Z_]*?)-.*/' , $ prefix ) , $ property -> getName ( ) , $ matches ) ; if ( $ matches ) { $ locales [ $ matches [ 1 ] ] = $ matches [ 1 ] ; } } return array_values ( array_unique ( $ locales ) ) ; }
Return the concrete localizations for the given document .
10,991
public function getConcreteLocales ( $ document ) { $ locales = $ this -> getLocales ( $ document ) ; if ( $ document instanceof ShadowLocaleBehavior ) { $ locales = array_diff ( $ locales , array_keys ( $ this -> getShadowLocales ( $ document ) ) ) ; } return array_values ( $ locales ) ; }
Return locales which are not shadows .
10,992
public function getShadowLocales ( ShadowLocaleBehavior $ document ) { $ shadowLocales = [ ] ; $ locales = $ this -> getLocales ( $ document ) ; $ node = $ this -> getNode ( $ document ) ; foreach ( $ locales as $ locale ) { $ shadowEnabledName = $ this -> encoder -> localizedSystemName ( ShadowLocaleSubscriber :: SHADOW_ENABLED_FIELD , $ locale ) ; $ shadowLocaleName = $ this -> encoder -> localizedSystemName ( ShadowLocaleSubscriber :: SHADOW_LOCALE_FIELD , $ locale ) ; if ( $ node -> getPropertyValueWithDefault ( $ shadowEnabledName , false ) ) { $ shadowLocales [ $ locale ] = $ node -> getPropertyValue ( $ shadowLocaleName ) ; } } return $ shadowLocales ; }
Return the enabled shadow locales for the given document .
10,993
public function getPublishedLocales ( ShadowLocaleBehavior $ document ) { $ node = $ this -> getNode ( $ document ) ; $ locales = $ this -> getLocales ( $ document ) ; $ publishedLocales = [ ] ; foreach ( $ locales as $ locale ) { $ publishedPropertyName = $ this -> encoder -> localizedSystemName ( WorkflowStageSubscriber :: PUBLISHED_FIELD , $ locale ) ; if ( $ node -> getPropertyValueWithDefault ( $ publishedPropertyName , false ) ) { $ publishedLocales [ ] = $ locale ; } } return $ publishedLocales ; }
Return the published locales for the given document .
10,994
public function getLocalizedUrlsForPage ( BasePageDocument $ page ) { $ localizedUrls = [ ] ; $ webspaceKey = $ this -> getWebspace ( $ page ) ; $ webspace = $ this -> webspaceManager -> findWebspaceByKey ( $ webspaceKey ) ; $ node = $ this -> getNode ( $ page ) ; $ structure = $ this -> getStructureMetadata ( $ page ) ; $ resourceLocatorProperty = $ structure -> getPropertyByTagName ( 'sulu.rlp' ) ; foreach ( $ webspace -> getAllLocalizations ( ) as $ localization ) { $ resolvedLocale = $ localization -> getLocale ( ) ; $ locale = $ resolvedLocale ; $ shadowEnabledName = $ this -> encoder -> localizedSystemName ( ShadowLocaleSubscriber :: SHADOW_ENABLED_FIELD , $ resolvedLocale ) ; if ( true === $ node -> getPropertyValueWithDefault ( $ shadowEnabledName , false ) ) { $ shadowLocaleName = $ this -> encoder -> localizedSystemName ( ShadowLocaleSubscriber :: SHADOW_LOCALE_FIELD , $ resolvedLocale ) ; $ resolvedLocale = $ node -> getPropertyValue ( $ shadowLocaleName ) ; } $ stageName = $ this -> encoder -> localizedSystemName ( WorkflowStageSubscriber :: WORKFLOW_STAGE_FIELD , $ resolvedLocale ) ; if ( false === $ node -> hasProperty ( $ stageName ) ) { continue ; } $ stage = $ node -> getProperty ( $ stageName ) ; if ( WorkflowStage :: PUBLISHED !== $ stage -> getValue ( ) ) { continue ; } $ url = $ node -> getPropertyValueWithDefault ( $ this -> encoder -> localizedContentName ( $ resourceLocatorProperty -> getName ( ) , $ locale ) , null ) ; if ( null === $ url ) { continue ; } $ localizedUrls [ $ locale ] = $ url ; } return $ localizedUrls ; }
Returns urls for given page for all locales in webspace .
10,995
public function postGenerateAction ( Request $ request ) { $ parentUuid = $ this -> getRequestParameter ( $ request , 'parent' ) ; $ parts = $ this -> getRequestParameter ( $ request , 'parts' , true ) ; $ templateKey = $ this -> getRequestParameter ( $ request , 'template' , true ) ; $ webspaceKey = $ this -> getRequestParameter ( $ request , 'webspace' , true ) ; $ languageCode = $ this -> getLocale ( $ request ) ; $ result = $ this -> getResourceLocatorRepository ( ) -> generate ( $ parts , $ parentUuid , $ webspaceKey , $ languageCode , $ templateKey ) ; return $ this -> handleView ( $ this -> view ( $ result ) ) ; }
return resource - locator for sub - node .
10,996
public function cgetAction ( $ id , Request $ request ) { list ( $ webspaceKey , $ languageCode ) = $ this -> getWebspaceAndLanguage ( $ request ) ; $ result = $ this -> getResourceLocatorRepository ( ) -> getHistory ( $ id , $ webspaceKey , $ languageCode ) ; return $ this -> handleView ( $ this -> view ( $ result ) ) ; }
return all resource locators for given node .
10,997
public function cdeleteAction ( $ id , Request $ request ) { list ( $ webspaceKey , $ languageCode ) = $ this -> getWebspaceAndLanguage ( $ request ) ; $ path = $ this -> getRequestParameter ( $ request , 'ids' , true ) ; $ this -> getResourceLocatorRepository ( ) -> delete ( $ path , $ webspaceKey , $ languageCode ) ; $ this -> getDocumentManager ( ) -> flush ( ) ; return $ this -> handleView ( $ this -> view ( ) ) ; }
deletes resource locator with given path .
10,998
private function getWebspaceAndLanguage ( Request $ request ) { $ webspaceKey = $ this -> getRequestParameter ( $ request , 'webspace' , true ) ; $ languageCode = $ this -> getRequestParameter ( $ request , 'language' , true ) ; return [ $ webspaceKey , $ languageCode ] ; }
returns webspacekey and languagecode .
10,999
private function generateNavigation ( $ contents , $ webspace , $ language , $ flat = false , $ context = null , $ breakOnNotInNavigation = false , $ recursive = true ) { $ result = [ ] ; foreach ( $ contents as $ content ) { if ( $ this -> inNavigation ( $ content , $ context ) ) { $ url = $ content -> getResourceLocator ( ) ; $ title = $ content -> getNodeName ( ) ; $ children = $ recursive ? $ this -> generateChildNavigation ( $ content , $ webspace , $ language , $ flat , $ context ) : [ ] ; if ( false === $ flat ) { $ result [ ] = new NavigationItem ( $ title , $ url , isset ( $ content -> getExt ( ) [ 'excerpt' ] ) ? $ content -> getExt ( ) [ 'excerpt' ] : null , $ children , $ content -> getUuid ( ) , $ content -> getNodeType ( ) ) ; } else { $ result [ ] = new NavigationItem ( $ title , $ url , isset ( $ content -> getExt ( ) [ 'excerpt' ] ) ? $ content -> getExt ( ) [ 'excerpt' ] : null , null , $ content -> getUuid ( ) , $ content -> getNodeType ( ) ) ; $ result = array_merge ( $ result , $ children ) ; } } elseif ( true === $ flat ) { $ children = $ recursive ? $ this -> generateChildNavigation ( $ content , $ webspace , $ language , $ flat , $ context ) : [ ] ; $ result = array_merge ( $ result , $ children ) ; } elseif ( $ breakOnNotInNavigation ) { break ; } } return $ result ; }
generate navigation items for given contents .