idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
11,400
public function getLanguagesForNode ( NodeInterface $ node ) { $ languages = [ ] ; foreach ( $ node -> getProperties ( ) as $ property ) { preg_match ( '/^' . $ this -> languageNamespace . ':([a-zA-Z_]*?)-changer/' , $ property -> getName ( ) , $ matches ) ; if ( $ matches ) { $ languages [ $ matches [ 1 ] ] = $ matches [ 1 ] ; } } return array_values ( $ languages ) ; }
Return the languages that are currently registered on the given PHPCR node .
11,401
public function getStructureTypeForNode ( NodeInterface $ node ) { $ mixinTypes = $ node -> getPropertyValueWithDefault ( 'jcr:mixinTypes' , [ ] ) ; if ( in_array ( 'sulu:' . Structure :: TYPE_PAGE , $ mixinTypes ) ) { return Structure :: TYPE_PAGE ; } if ( in_array ( 'sulu:' . Structure :: TYPE_SNIPPET , $ mixinTypes ) ) { return Structure :: TYPE_SNIPPET ; } return ; }
Return the structure type for the given node .
11,402
public function getBaseSnippetPath ( $ type = null ) { $ path = '/' . $ this -> getPath ( 'base' ) . '/' . $ this -> getPath ( 'snippet' ) ; if ( $ type ) { $ path .= '/' . $ type ; } return $ path ; }
Returns the path for the base snippet of the given type resp . of all types if not given .
11,403
public function getBaseSnippetUuid ( $ type = null ) { try { return $ this -> session -> getNode ( $ this -> getBaseSnippetPath ( $ type ) ) -> getIdentifier ( ) ; } catch ( PathNotFoundException $ e ) { $ snippetStructures = array_map ( function ( StructureMetadata $ structureMetadata ) { return $ structureMetadata -> getName ( ) ; } , $ this -> structureMetadataFactory -> getStructures ( 'snippet' ) ) ; if ( in_array ( $ type , $ snippetStructures ) ) { return null ; } throw new \ InvalidArgumentException ( sprintf ( 'Snippet type "%s" not available, available snippet types are: [%s]' , $ type , implode ( ', ' , $ snippetStructures ) ) ) ; } }
Returns the uuid for the base snippet of the given type resp . of all types if not given .
11,404
public function extractSnippetTypeFromPath ( $ path ) { if ( '/' !== substr ( $ path , 0 , 1 ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Path must be absolute, got "%s"' , $ path ) ) ; } $ snippetsPath = $ this -> getBaseSnippetPath ( ) . '/' ; $ newPath = PathHelper :: getParentPath ( $ path ) ; $ newPath = substr ( $ newPath , strlen ( $ snippetsPath ) ) ; if ( false === $ newPath ) { throw new \ InvalidArgumentException ( sprintf ( 'Cannot extract snippet template type from path "%s"' , $ path ) ) ; } return $ newPath ; }
Extract the snippet path from the given path .
11,405
public function getTranslatedProperty ( $ property , $ locale , $ prefix = null ) { return new TranslatedProperty ( $ property , $ locale , $ this -> languageNamespace , $ prefix ) ; }
Return translated property .
11,406
public function getValues ( ) { $ values = $ this -> entity -> getValues ( ) ; $ result = [ ] ; if ( $ values ) { foreach ( $ values as $ value ) { $ result [ ] = new OperatorValue ( $ value , $ this -> locale ) ; } return $ result ; } return ; }
Get values .
11,407
public function onResponse ( FilterResponseEvent $ event ) { if ( $ this -> preview || 0 !== strpos ( $ event -> getResponse ( ) -> headers -> get ( 'Content-Type' ) , 'text/html' ) || null === $ this -> requestAnalyzer -> getPortalInformation ( ) ) { return ; } $ portalUrl = $ this -> requestAnalyzer -> getAttribute ( 'urlExpression' ) ; $ analyticsArray = $ this -> analyticsRepository -> findByUrl ( $ portalUrl , $ this -> requestAnalyzer -> getPortalInformation ( ) -> getWebspaceKey ( ) , $ this -> environment ) ; $ analyticsContent = [ ] ; foreach ( $ analyticsArray as $ analytics ) { $ analyticsContent = $ this -> generateAnalyticsContent ( $ analyticsContent , $ analytics ) ; } $ response = $ event -> getResponse ( ) ; $ response -> setContent ( $ this -> setAnalyticsContent ( $ response -> getContent ( ) , $ analyticsContent ) ) ; }
Appends analytics scripts into body .
11,408
protected function generateAnalyticsContent ( array $ analyticsContent , Analytics $ analytics ) { foreach ( array_keys ( self :: $ positions ) as $ position ) { $ template = 'SuluWebsiteBundle:Analytics:' . $ analytics -> getType ( ) . '/' . $ position . '.html.twig' ; if ( ! $ this -> engine -> exists ( $ template ) ) { continue ; } $ content = $ this -> engine -> render ( $ template , [ 'analytics' => $ analytics ] ) ; if ( ! $ content ) { continue ; } if ( ! array_key_exists ( $ position , $ analyticsContent ) ) { $ analyticsContent [ $ position ] = '' ; } $ analyticsContent [ $ position ] .= $ content ; } return $ analyticsContent ; }
Generate content for each possible position .
11,409
protected function setAnalyticsContent ( $ responseContent , array $ analyticsContent ) { foreach ( $ analyticsContent as $ id => $ content ) { if ( ! $ content ) { continue ; } $ responseContent = preg_replace ( self :: $ positions [ $ id ] [ 'regex' ] , sprintf ( self :: $ positions [ $ id ] [ 'sprintf' ] , $ content ) , $ responseContent ) ; } return $ responseContent ; }
Set the generated content for each position .
11,410
public function setFilter ( \ Sulu \ Bundle \ ResourceBundle \ Entity \ Filter $ filter ) { $ this -> filter = $ filter ; return $ this ; }
Set filter .
11,411
private function getUniqueFileName ( string $ folder , string $ fileName , int $ counter = 0 ) : string { $ newFileName = $ fileName ; if ( $ counter > 0 ) { $ fileNameParts = explode ( '.' , $ fileName , 2 ) ; $ newFileName = $ fileNameParts [ 0 ] . '-' . $ counter ; if ( isset ( $ fileNameParts [ 1 ] ) ) { $ newFileName .= '.' . $ fileNameParts [ 1 ] ; } } $ filePath = $ this -> getPathByFolderAndFileName ( $ folder , $ newFileName ) ; $ this -> logger -> debug ( 'Check FilePath: ' . $ filePath ) ; if ( ! $ this -> filesystem -> exists ( $ filePath ) ) { return $ newFileName ; } ++ $ counter ; return $ this -> getUniqueFileName ( $ folder , $ fileName , $ counter ) ; }
Get a unique filename in path .
11,412
public function cgetAction ( Request $ request ) { $ locale = $ this -> getLocale ( $ request ) ; $ type = $ request -> query -> get ( 'type' , null ) ? : null ; $ idsString = $ request -> get ( 'ids' ) ; if ( $ idsString ) { $ ids = explode ( ',' , $ idsString ) ; $ snippets = $ this -> snippetRepository -> getSnippetsByUuids ( $ ids , $ locale ) ; $ total = count ( $ snippets ) ; } else { $ snippets = $ this -> snippetRepository -> getSnippets ( $ locale , $ type , $ this -> listRestHelper -> getOffset ( ) , $ this -> listRestHelper -> getLimit ( ) , $ this -> listRestHelper -> getSearchPattern ( ) , $ this -> listRestHelper -> getSortColumn ( ) , $ this -> listRestHelper -> getSortOrder ( ) ) ; $ total = $ this -> snippetRepository -> getSnippetsAmount ( $ locale , $ type , $ this -> listRestHelper -> getSearchPattern ( ) , $ this -> listRestHelper -> getSortColumn ( ) , $ this -> listRestHelper -> getSortOrder ( ) ) ; } $ data = new ListRepresentation ( $ snippets , 'snippets' , 'get_snippets' , $ request -> query -> all ( ) , $ this -> listRestHelper -> getPage ( ) , $ this -> listRestHelper -> getLimit ( ) , $ total ) ; return $ this -> viewHandler -> handle ( View :: create ( $ data ) ) ; }
Returns list of snippets .
11,413
public function getAction ( Request $ request , $ id = null ) { $ locale = $ this -> getLocale ( $ request ) ; $ snippet = $ this -> findDocument ( $ id , $ locale ) ; $ view = View :: create ( $ snippet ) ; return $ this -> viewHandler -> handle ( $ view ) ; }
Returns snippet by ID .
11,414
public function postAction ( Request $ request ) { $ document = $ this -> documentManager -> create ( Structure :: TYPE_SNIPPET ) ; $ form = $ this -> processForm ( $ request , $ document ) ; return $ this -> handleView ( $ form -> getData ( ) ) ; }
Saves a new snippet .
11,415
public function putAction ( Request $ request , $ id ) { $ document = $ this -> findDocument ( $ id , $ this -> getLocale ( $ request ) ) ; $ this -> requestHashChecker -> checkHash ( $ request , $ document , $ document -> getUuid ( ) ) ; if ( ! $ this -> checkAreaSnippet ( $ request , $ document ) ) { return new JsonResponse ( [ 'structures' => [ ] , 'other' => [ ] , 'isDefault' => true , ] , 409 ) ; } $ this -> processForm ( $ request , $ document ) ; return $ this -> handleView ( $ document ) ; }
Saves a new existing snippet .
11,416
public function deleteAction ( Request $ request , $ id ) { $ locale = $ this -> getLocale ( $ request ) ; $ webspaceKey = $ request -> query -> get ( 'webspace' , null ) ; $ references = $ this -> snippetRepository -> getReferences ( $ id ) ; if ( count ( $ references ) > 0 ) { $ force = $ request -> headers -> get ( 'SuluForceRemove' , false ) ; if ( $ force ) { $ this -> contentMapper -> delete ( $ id , $ webspaceKey , true ) ; } else { return $ this -> getReferentialIntegrityResponse ( $ webspaceKey , $ references , $ id , $ locale ) ; } } else { $ this -> contentMapper -> delete ( $ id , $ webspaceKey ) ; } return new JsonResponse ( ) ; }
Deletes an existing Snippet .
11,417
public function postTriggerAction ( $ id , Request $ request ) { $ view = null ; $ snippet = null ; $ locale = $ this -> getLocale ( $ request ) ; $ action = $ this -> getRequestParameter ( $ request , 'action' , true ) ; try { switch ( $ action ) { case 'copy-locale' : $ destLocales = explode ( ',' , $ this -> getRequestParameter ( $ request , 'dest' , true ) ) ; $ snippet = $ this -> snippetRepository -> copyLocale ( $ id , $ this -> getUser ( ) -> getId ( ) , $ locale , $ destLocales ) ; foreach ( $ destLocales as $ destLocale ) { $ destSnippet = $ this -> findDocument ( $ id , $ destLocale ) ; $ this -> documentManager -> publish ( $ destSnippet , $ destLocale ) ; } $ this -> documentManager -> flush ( ) ; break ; default : throw new RestException ( 'Unrecognized action: ' . $ action ) ; } $ view = View :: create ( $ this -> decorateSnippet ( $ snippet -> toArray ( ) , $ locale ) , null !== $ snippet ? 200 : 204 ) ; } catch ( RestException $ exc ) { $ view = View :: create ( $ exc -> toArray ( ) , 400 ) ; } return $ this -> viewHandler -> handle ( $ view ) ; }
trigger a action for given snippet specified over get - action parameter .
11,418
private function decorateSnippet ( array $ snippet , $ locale ) { return array_merge ( $ snippet , [ '_links' => [ 'self' => $ this -> urlGenerator -> generate ( 'get_snippet' , [ 'id' => $ snippet [ 'id' ] , 'language' => $ locale ] ) , 'delete' => $ this -> urlGenerator -> generate ( 'delete_snippet' , [ 'id' => $ snippet [ 'id' ] , 'language' => $ locale ] ) , 'new' => $ this -> urlGenerator -> generate ( 'post_snippet' , [ 'language' => $ locale ] ) , 'update' => $ this -> urlGenerator -> generate ( 'put_snippet' , [ 'id' => $ snippet [ 'id' ] , 'language' => $ locale ] ) , ] , ] ) ; }
Decorate snippet for HATEOAS .
11,419
private function getReferentialIntegrityResponse ( $ webspace , $ references , $ id , $ locale ) { $ data = [ 'structures' => [ ] , 'other' => [ ] , 'isDefault' => $ this -> defaultSnippetManager -> isDefault ( $ id ) , ] ; foreach ( $ references as $ reference ) { if ( $ reference -> getParent ( ) -> isNodeType ( 'sulu:page' ) ) { $ content = $ this -> contentMapper -> load ( $ reference -> getParent ( ) -> getIdentifier ( ) , $ webspace , $ locale , true ) ; $ data [ 'structures' ] [ ] = $ content -> toArray ( ) ; } else { $ data [ 'other' ] [ ] = $ reference -> getParent ( ) -> getPath ( ) ; } } return new JsonResponse ( $ data , 409 ) ; }
Return a response for the case where there is an referential integrity violation .
11,420
private function createSql2Query ( $ sql2 , $ limit = null , $ offset = null ) { $ queryManager = $ this -> sessionManager -> getSession ( ) -> getWorkspace ( ) -> getQueryManager ( ) ; $ query = $ queryManager -> createQuery ( $ sql2 , 'JCR-SQL2' ) ; if ( $ limit ) { $ query -> setLimit ( $ limit ) ; } if ( $ offset ) { $ query -> setOffset ( $ offset ) ; } return $ query ; }
returns a sql2 query .
11,421
public function handlePersist ( PersistEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! ( $ document instanceof CustomUrlBehavior ) ) { return ; } $ webspaceKey = $ this -> inspector -> getWebspace ( $ document ) ; $ domain = $ this -> generator -> generate ( $ document -> getBaseDomain ( ) , $ document -> getDomainParts ( ) ) ; $ locale = $ this -> webspaceManager -> findWebspaceByKey ( $ webspaceKey ) -> getLocalization ( $ document -> getTargetLocale ( ) ) ; $ route = $ this -> createRoute ( $ domain , $ document , $ locale , $ event -> getLocale ( ) , $ this -> getRoutesPath ( $ webspaceKey ) ) ; $ this -> updateOldReferrers ( $ document , $ route , $ event -> getLocale ( ) ) ; }
Creates routes for persisted custom - url .
11,422
protected function createRoute ( $ domain , CustomUrlBehavior $ document , Localization $ locale , $ persistedLocale , $ routesPath ) { $ path = sprintf ( '%s/%s' , $ routesPath , $ domain ) ; $ routeDocument = $ this -> findOrCreateRoute ( $ path , $ persistedLocale , $ document , $ domain ) ; $ routeDocument -> setTargetDocument ( $ document ) ; $ routeDocument -> setLocale ( $ locale -> getLocale ( ) ) ; $ routeDocument -> setHistory ( false ) ; $ this -> documentManager -> persist ( $ routeDocument , $ persistedLocale , [ 'path' => $ path , 'auto_create' => true , ] ) ; $ this -> documentManager -> publish ( $ routeDocument , $ persistedLocale ) ; return $ routeDocument ; }
Create route - document for given domain .
11,423
protected function findOrCreateRoute ( $ path , $ locale , CustomUrlBehavior $ document , $ route ) { try { $ routeDocument = $ this -> documentManager -> find ( $ path , $ locale ) ; } catch ( DocumentNotFoundException $ ex ) { return $ this -> documentManager -> create ( 'custom_url_route' ) ; } if ( ! $ routeDocument instanceof RouteDocument || $ routeDocument -> getTargetDocument ( ) -> getUuid ( ) !== $ document -> getUuid ( ) ) { throw new ResourceLocatorAlreadyExistsException ( $ route , $ document -> getTitle ( ) ) ; } return $ routeDocument ; }
Find or create route - document for given path .
11,424
public function handleRemove ( RemoveEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! ( $ document instanceof CustomUrlBehavior ) ) { return ; } foreach ( $ this -> inspector -> getReferrers ( $ document ) as $ referrer ) { if ( $ referrer instanceof RouteBehavior ) { $ this -> documentManager -> remove ( $ referrer ) ; } } }
Removes the routes for the given document .
11,425
public function findByUrlAndEnvironment ( $ url , $ environment ) { $ queryBuilder = $ this -> createQueryBuilder ( 'u' ) -> where ( 'u.url = :url' ) -> andWhere ( 'u.environment = :environment' ) ; $ query = $ queryBuilder -> getQuery ( ) ; $ query -> setParameter ( 'url' , $ url ) ; $ query -> setParameter ( 'environment' , $ environment ) ; try { return $ query -> getSingleResult ( ) ; } catch ( NoResultException $ ex ) { return ; } }
Returns domain with given url and environment .
11,426
private function getHostLength ( ) { $ hostLength = strpos ( $ this -> url , '/' ) ; $ hostLength = ( false === $ hostLength ) ? strlen ( $ this -> url ) : $ hostLength ; return $ hostLength ; }
Calculate the length of the host part of the URL .
11,427
protected function createMask ( $ maskPath , $ width , $ height ) { $ mask = $ this -> imagine -> open ( $ maskPath ) ; $ mask -> resize ( new Box ( $ width ? : 1 , $ height ? : 1 ) ) ; return $ mask ; }
Create mask .
11,428
public function addConfigParams ( JsConfigInterface $ params ) { $ this -> pool = array_merge ( $ this -> pool , [ $ params -> getName ( ) => $ params -> getParameters ( ) ] ) ; }
Adds a new config parameter .
11,429
private function loadPropertyMetadata ( \ DOMXPath $ xpath , \ DOMNode $ propertyNode ) { $ propertyMetadata = null ; switch ( $ propertyNode -> nodeName ) { case 'concatenation-property' : $ propertyMetadata = $ this -> loadConcatenationPropertyMetadata ( $ xpath , $ propertyNode ) ; break ; case 'identity-property' : $ propertyMetadata = $ this -> loadIdentityPropertyMetadata ( $ xpath , $ propertyNode ) ; break ; case 'group-concat-property' : $ propertyMetadata = $ this -> loadGroupConcatPropertyMetadata ( $ xpath , $ propertyNode ) ; break ; case 'case-property' : $ propertyMetadata = $ this -> loadCasePropertyMetadata ( $ xpath , $ propertyNode ) ; break ; case 'count-property' : $ propertyMetadata = $ this -> loadCountPropertyMetadata ( $ xpath , $ propertyNode ) ; break ; case 'property' : $ propertyMetadata = $ this -> loadSinglePropertyMetadata ( $ xpath , $ propertyNode ) ; break ; default : throw new \ InvalidArgumentException ( sprintf ( 'The tag "%s" cannot be handled by this loader' , $ propertyNode -> nodeName ) ) ; } if ( null !== $ translation = XmlUtil :: getValueFromXPath ( '@translation' , $ xpath , $ propertyNode ) ) { $ propertyMetadata -> setTranslation ( $ translation ) ; } if ( null !== $ type = XmlUtil :: getValueFromXPath ( '@type' , $ xpath , $ propertyNode ) ) { $ propertyMetadata -> setType ( $ type ) ; } $ propertyMetadata -> setVisibility ( XmlUtil :: getValueFromXPath ( '@visibility' , $ xpath , $ propertyNode , FieldDescriptorInterface :: VISIBILITY_NO ) ) ; $ propertyMetadata -> setSearchability ( XmlUtil :: getValueFromXPath ( '@searchability' , $ xpath , $ propertyNode , FieldDescriptorInterface :: SEARCHABILITY_NEVER ) ) ; $ propertyMetadata -> setSortable ( XmlUtil :: getBooleanValueFromXPath ( '@sortable' , $ xpath , $ propertyNode , true ) ) ; $ propertyMetadata -> setFilterType ( XmlUtil :: getValueFromXPath ( '@filter-type' , $ xpath , $ propertyNode ) ) ; $ propertyMetadata -> setFilterTypeParameters ( $ this -> getFilterTypeParameters ( $ xpath , $ propertyNode ) ) ; return $ propertyMetadata ; }
Extracts attributes from dom - node to create a new property - metadata object .
11,430
protected function getFilterTypeParameters ( \ DOMXPath $ xpath , \ DOMNode $ propertyNode ) { $ parameters = [ ] ; foreach ( $ xpath -> query ( 'x:filter-type-parameters/x:parameter' , $ propertyNode ) as $ parameterNode ) { $ key = XmlUtil :: getValueFromXPath ( '@key' , $ xpath , $ parameterNode ) ; $ parameters [ $ key ] = $ this -> parameterBag -> resolveValue ( trim ( $ parameterNode -> nodeValue ) ) ; } return $ parameters ; }
Extracts filter type parameters from dom - node .
11,431
public function queryAction ( Request $ request ) { $ geolocatorName = $ request -> get ( 'providerName' ) ; $ query = $ request -> get ( 'query' ) ; try { $ geolocator = $ this -> geolocatorManager -> get ( $ geolocatorName ) ; } catch ( GeolocatorNotFoundException $ e ) { throw new NotFoundHttpException ( sprintf ( 'Wrapped "%s"' , $ e -> getMessage ( ) ) , $ e ) ; } $ res = $ geolocator -> locate ( $ query ) ; return new JsonResponse ( [ '_embedded' => [ 'locations' => $ res -> toArray ( ) ] ] ) ; }
Query the configured geolocation service .
11,432
private function preload ( $ attributesByTag , $ locale , $ published = true ) { $ hrefsByType = [ ] ; foreach ( $ attributesByTag as $ attributes ) { $ provider = $ this -> getValue ( $ attributes , 'provider' , self :: DEFAULT_PROVIDER ) ; if ( ! array_key_exists ( $ provider , $ hrefsByType ) ) { $ hrefsByType [ $ provider ] = [ ] ; } $ hrefsByType [ $ provider ] [ ] = $ attributes [ 'href' ] ; } $ result = [ ] ; foreach ( $ hrefsByType as $ provider => $ hrefs ) { $ items = $ this -> linkProviderPool -> getProvider ( $ provider ) -> preload ( array_unique ( $ hrefs ) , $ locale , $ published ) ; foreach ( $ items as $ item ) { $ result [ $ provider . '-' . $ item -> getId ( ) ] = $ item ; } } return $ result ; }
Return items for given attributes .
11,433
private function getValue ( array $ attributes , $ name , $ default = null ) { if ( array_key_exists ( $ name , $ attributes ) && ! empty ( $ attributes [ $ name ] ) ) { return $ attributes [ $ name ] ; } return $ default ; }
Returns attribute identified by name or default if not exists .
11,434
private function getBasePath ( $ uuid = null , $ default = 1 ) { if ( null !== $ uuid ) { return str_replace ( '{uuid}' , $ uuid , $ this -> apiBasePath [ 2 ] ) ; } else { return $ this -> apiBasePath [ $ default ] ; } }
returns base path fo given uuid .
11,435
private function getSnippets ( PropertyInterface $ property ) { $ page = $ property -> getStructure ( ) ; $ webspaceKey = $ page -> getWebspaceKey ( ) ; $ locale = $ page -> getLanguageCode ( ) ; $ shadowLocale = null ; if ( $ page -> getIsShadow ( ) ) { $ shadowLocale = $ page -> getShadowBaseLanguage ( ) ; } $ refs = $ property -> getValue ( ) ; $ ids = $ this -> getUuids ( $ refs ) ; $ snippetType = $ this -> getParameterValue ( $ property -> getParams ( ) , 'snippetType' ) ; $ default = $ this -> getParameterValue ( $ property -> getParams ( ) , 'default' , false ) ; $ snippetArea = $ default ; if ( true === $ snippetArea || 'true' === $ snippetArea ) { $ snippetArea = $ snippetType ; } if ( empty ( $ ids ) && $ snippetArea && $ this -> defaultEnabled ) { $ ids = $ this -> loadSnippetAreaIds ( $ webspaceKey , $ snippetArea , $ locale ) ; } return $ this -> snippetResolver -> resolve ( $ ids , $ webspaceKey , $ locale , $ shadowLocale ) ; }
Returns snippets with given property value .
11,436
private function getParameterValue ( array $ parameter , $ name , $ default = null ) { if ( ! array_key_exists ( $ name , $ parameter ) ) { return $ default ; } return $ parameter [ $ name ] -> getValue ( ) ; }
Returns value of parameter . If parameter not exists the default will be returned .
11,437
protected function getPropertyData ( PropertyMetadata $ property , $ propertyValue ) { return $ this -> createProperty ( $ property -> getName ( ) , $ this -> exportManager -> export ( $ property -> getType ( ) , $ propertyValue ) , $ this -> exportManager -> getOptions ( $ property -> getType ( ) , $ this -> format ) , $ property -> getType ( ) ) ; }
Creates and returns a property - array .
11,438
protected function getBlockPropertyData ( BlockMetadata $ property , $ propertyValue ) { $ children = [ ] ; $ blockDataList = $ this -> exportManager -> export ( $ property -> getType ( ) , $ propertyValue ) ; foreach ( $ blockDataList as $ blockData ) { $ blockType = $ blockData [ 'type' ] ; $ block = $ this -> getPropertiesContentData ( $ property -> getComponentByName ( $ blockType ) -> getChildren ( ) , $ blockData ) ; $ block [ 'type' ] = $ this -> createProperty ( 'type' , $ blockType , $ this -> exportManager -> getOptions ( $ property -> getType ( ) , $ this -> format ) , $ property -> getType ( ) . '_type' ) ; $ children [ ] = $ block ; } return $ this -> createProperty ( $ property -> getName ( ) , null , $ this -> exportManager -> getOptions ( $ property -> getType ( ) , $ this -> format ) , $ property -> getType ( ) , $ children ) ; }
Creates and Returns a property - array for content - type Block .
11,439
protected function getPropertiesContentData ( $ properties , $ propertyValues ) { $ contentData = [ ] ; foreach ( $ properties as $ property ) { if ( $ this -> exportManager -> hasExport ( $ property -> getType ( ) , $ this -> format ) ) { if ( ! isset ( $ propertyValues [ $ property -> getName ( ) ] ) ) { continue ; } $ propertyValue = $ propertyValues [ $ property -> getName ( ) ] ; if ( $ property instanceof BlockMetadata ) { $ data = $ this -> getBlockPropertyData ( $ property , $ propertyValue ) ; } else { $ data = $ this -> getPropertyData ( $ property , $ propertyValue ) ; } $ contentData [ $ property -> getName ( ) ] = $ data ; } } return $ contentData ; }
Returns the Content as a flat array .
11,440
protected function getContentData ( $ document , $ locale ) { $ loadedDocument = $ this -> documentManager -> find ( $ document -> getUuid ( ) , $ locale ) ; $ metaData = $ this -> documentInspector -> getStructureMetadata ( $ document ) ; $ propertyValues = $ loadedDocument -> getStructure ( ) -> toArray ( ) ; $ properties = $ metaData -> getProperties ( ) ; $ contentData = $ this -> getPropertiesContentData ( $ properties , $ propertyValues ) ; return $ contentData ; }
Returns a array of the given content data of the document .
11,441
protected function getTemplate ( $ format ) { if ( ! isset ( $ this -> formatFilePaths [ $ format ] ) ) { throw new \ Exception ( sprintf ( 'No format "%s" configured for Snippet export' , $ format ) ) ; } $ templatePath = $ this -> formatFilePaths [ $ format ] ; if ( ! $ this -> templating -> exists ( $ templatePath ) ) { throw new \ Exception ( sprintf ( 'No template file "%s" found for Snippet export' , $ format ) ) ; } return $ templatePath ; }
Returns export template for given format like XLIFF1 . 2 .
11,442
private function persistReference ( NodeInterface $ node , DocumentAccessor $ accessor , $ fieldName , $ locale , $ fieldMapping ) { $ referenceDocument = $ accessor -> get ( $ fieldName ) ; if ( ! $ referenceDocument ) { return ; } if ( $ fieldMapping [ 'multiple' ] ) { throw new \ InvalidArgumentException ( sprintf ( 'Mapping references as multiple not currently supported (when mapping "%s")' , $ fieldName ) ) ; } try { $ referenceNode = $ this -> documentRegistry -> getNodeForDocument ( $ referenceDocument ) ; $ phpcrName = $ this -> encoder -> encode ( $ fieldMapping [ 'encoding' ] , $ fieldMapping [ 'property' ] , $ locale ) ; $ node -> setProperty ( $ phpcrName , $ referenceNode ) ; } catch ( InvalidLocaleException $ ex ) { return ; } }
Persist a reference field type .
11,443
private function persistGeneric ( NodeInterface $ node , DocumentAccessor $ accessor , $ fieldName , $ locale , array $ fieldMapping ) { try { $ phpcrName = $ this -> encoder -> encode ( $ fieldMapping [ 'encoding' ] , $ fieldMapping [ 'property' ] , $ locale ) ; $ value = $ accessor -> get ( $ fieldName ) ; $ this -> validateFieldValue ( $ value , $ fieldName , $ fieldMapping ) ; $ node -> setProperty ( $ phpcrName , $ value ) ; } catch ( InvalidLocaleException $ ex ) { return ; } }
Persist scalar field types .
11,444
private function hydrateReferenceField ( NodeInterface $ node , $ document , DocumentAccessor $ accessor , $ fieldName , $ locale , array $ fieldMapping , array $ options ) { try { $ phpcrName = $ this -> encoder -> encode ( $ fieldMapping [ 'encoding' ] , $ fieldMapping [ 'property' ] , $ locale ) ; $ referencedNode = $ node -> getPropertyValueWithDefault ( $ phpcrName , $ this -> getDefaultValue ( $ fieldMapping ) ) ; if ( $ referencedNode ) { $ accessor -> set ( $ fieldName , $ this -> proxyFactory -> createProxyForNode ( $ document , $ referencedNode , $ options ) ) ; } } catch ( InvalidLocaleException $ ex ) { return ; } }
Hydrate reference field types .
11,445
private function hydrateGenericField ( NodeInterface $ node , DocumentAccessor $ accessor , $ fieldName , $ locale , array $ fieldMapping ) { try { $ phpcrName = $ this -> encoder -> encode ( $ fieldMapping [ 'encoding' ] , $ fieldMapping [ 'property' ] , $ locale ) ; $ value = $ node -> getPropertyValueWithDefault ( $ phpcrName , $ this -> getDefaultValue ( $ fieldMapping ) ) ; $ accessor -> set ( $ fieldName , $ value ) ; } catch ( InvalidLocaleException $ ex ) { return ; } }
Hydrate scalar field types .
11,446
private function appendPortalInformation ( Webspace $ webspace , Context $ context , JsonSerializationVisitor $ visitor ) { $ portalInformation = $ this -> webspaceManager -> getPortalInformationsByWebspaceKey ( $ this -> environment , $ webspace -> getKey ( ) ) ; $ portalInformation = $ context -> accept ( array_values ( $ portalInformation ) ) ; $ visitor -> addData ( 'portalInformation' , $ portalInformation ) ; }
Extract portal - information and add them to serialization .
11,447
private function appendUrls ( Webspace $ webspace , Context $ context , JsonSerializationVisitor $ visitor ) { $ urls = $ this -> webspaceUrlProvider -> getUrls ( $ webspace , $ this -> environment ) ; $ urls = $ context -> accept ( $ urls ) ; $ visitor -> addData ( 'urls' , $ urls ) ; }
Extract urls and add them to serialization .
11,448
private function appendCustomUrls ( Webspace $ webspace , Context $ context , JsonSerializationVisitor $ visitor ) { $ customUrls = [ ] ; foreach ( $ webspace -> getPortals ( ) as $ portal ) { $ customUrls = array_merge ( $ customUrls , $ this -> getCustomUrlsForEnvironment ( $ portal , $ portal -> getEnvironment ( $ this -> environment ) , $ context ) ) ; } $ customUrls = $ context -> accept ( $ customUrls ) ; $ visitor -> addData ( 'customUrls' , $ customUrls ) ; }
Extract custom - url and add them to serialization .
11,449
private function getCustomUrlsForEnvironment ( Portal $ portal , Environment $ environment , Context $ context ) { $ customUrls = [ ] ; foreach ( $ environment -> getCustomUrls ( ) as $ customUrl ) { $ customUrl = $ context -> accept ( $ customUrl ) ; $ customUrl [ 'locales' ] = $ context -> accept ( $ portal -> getLocalizations ( ) ) ; $ customUrls [ ] = $ customUrl ; } return $ customUrls ; }
Returns custom - url data with the connected locales .
11,450
public function onHit ( HitEvent $ event ) { if ( false === $ event -> getMetadata ( ) -> reflection -> isSubclassOf ( BasePageDocument :: class ) ) { return ; } $ document = $ event -> getHit ( ) -> getDocument ( ) ; if ( '/' !== $ document -> getUrl ( ) [ 0 ] ) { return ; } $ url = sprintf ( '%s/%s' , rtrim ( $ this -> requestAnalyzer -> getResourceLocatorPrefix ( ) , '/' ) , ltrim ( $ document -> getUrl ( ) , '/' ) ) ; $ document -> setUrl ( $ url ) ; }
Prefix url of document with current resourcelocator prefix .
11,451
public function onPostSerialize ( ObjectEvent $ event ) { $ visitor = $ event -> getVisitor ( ) ; $ document = $ event -> getObject ( ) ; if ( ! $ document instanceof PathBehavior || ! $ this -> documentRegistry -> hasDocument ( $ document ) ) { return ; } $ visitor -> addData ( 'path' , $ this -> documentInspector -> getContentPath ( $ document ) ) ; }
Adds the relative path to the serialization .
11,452
public function cgetAction ( Request $ request ) { $ checkForPermissions = $ request -> get ( 'checkForPermissions' , true ) ; $ locale = $ this -> getRequestParameter ( $ request , 'locale' , true ) ; $ webspaces = [ ] ; $ securityChecker = $ this -> get ( 'sulu_security.security_checker' ) ; foreach ( $ this -> get ( 'sulu_core.webspace.webspace_manager' ) -> getWebspaceCollection ( ) as $ webspace ) { if ( $ checkForPermissions ) { $ securityContext = $ this -> getSecurityContextByWebspace ( $ webspace -> getKey ( ) ) ; if ( ! $ securityChecker -> hasPermission ( new SecurityCondition ( $ securityContext ) , PermissionTypes :: VIEW ) ) { continue ; } } $ webspaces [ ] = $ webspace ; } $ context = new Context ( ) ; $ context -> setAttribute ( 'locale' , $ locale ) ; $ view = $ this -> view ( new CollectionRepresentation ( $ webspaces , 'webspaces' ) ) ; $ view -> setContext ( $ context ) ; return $ this -> handleView ( $ view ) ; }
Returns webspaces .
11,453
public function getAction ( $ webspaceKey ) { return $ this -> handleView ( $ this -> view ( $ this -> get ( 'sulu_core.webspace.webspace_manager' ) -> findWebspaceByKey ( $ webspaceKey ) ) ) ; }
Returns webspace config by key .
11,454
public function getItemsAction ( Request $ request ) { $ providerAlias = $ this -> getRequestParameter ( $ request , 'provider' , true ) ; $ filters = $ request -> query -> all ( ) ; $ filters [ 'excluded' ] = array_filter ( explode ( ',' , $ this -> getRequestParameter ( $ request , 'excluded' ) ) ) ; if ( isset ( $ filters [ 'categories' ] ) ) { $ filters [ 'categories' ] = explode ( ',' , $ this -> getRequestParameter ( $ request , 'categories' ) ) ; } if ( isset ( $ filters [ 'tags' ] ) ) { $ filters [ 'tags' ] = explode ( ',' , $ this -> getRequestParameter ( $ request , 'tags' ) ) ; } if ( isset ( $ filters [ 'sortBy' ] ) ) { $ filters [ 'sortBy' ] = explode ( ',' , $ this -> getRequestParameter ( $ request , 'sortBy' ) ) ; } $ filters = array_filter ( $ filters ) ; $ options = [ 'webspaceKey' => $ this -> getRequestParameter ( $ request , 'webspace' ) , 'locale' => $ this -> getLocale ( $ request ) , ] ; if ( isset ( $ filters [ 'tags' ] ) ) { $ filters [ 'tags' ] = $ this -> get ( 'sulu_tag.tag_manager' ) -> resolveTagNames ( $ filters [ 'tags' ] ) ; } $ dataProviderPool = $ this -> get ( 'sulu_page.smart_content.data_provider_pool' ) ; $ provider = $ dataProviderPool -> get ( $ providerAlias ) ; $ params = array_merge ( $ provider -> getDefaultPropertyParameter ( ) , $ this -> getParams ( json_decode ( $ request -> get ( 'params' , '{}' ) , true ) ) ) ; $ data = $ provider -> resolveDataItems ( $ filters , $ params , $ options , ( isset ( $ filters [ 'limitResult' ] ) ? $ filters [ 'limitResult' ] : null ) ) ; $ items = $ data -> getItems ( ) ; $ datasource = $ provider -> resolveDatasource ( $ request -> get ( 'dataSource' ) , [ ] , $ options ) ; return $ this -> handleView ( $ this -> view ( new ItemCollectionRepresentation ( $ items , $ datasource ) ) ) ; }
Resolves filter for smart - content UI .
11,455
private function getParams ( array $ params ) { $ result = [ ] ; foreach ( $ params as $ name => $ item ) { $ value = $ item [ 'value' ] ; if ( 'collection' === $ item [ 'type' ] ) { $ value = $ this -> getParams ( $ value ) ; } $ result [ $ name ] = new PropertyParameter ( $ name , $ value , $ item [ 'type' ] ) ; } return $ result ; }
Returns property - parameter .
11,456
private function addHistoryRedirectToRouteCollection ( Request $ request , RouteDocument $ routeDocument , RouteCollection $ collection , $ webspaceKey ) { $ resourceSegment = PathHelper :: relativizePath ( $ routeDocument -> getTargetDocument ( ) -> getPath ( ) , $ this -> getRoutesPath ( $ webspaceKey ) ) ; $ url = sprintf ( '%s://%s' , $ request -> getScheme ( ) , $ resourceSegment ) ; $ collection -> add ( uniqid ( 'custom_url_route_' , true ) , new Route ( $ this -> decodePathInfo ( $ request -> getPathInfo ( ) ) , [ '_controller' => 'SuluWebsiteBundle:Redirect:redirect' , '_finalized' => true , 'url' => $ url , ] ) ) ; return $ collection ; }
Add redirect to current custom - url .
11,457
private function loadPaginated ( array $ options , $ limit , $ page , $ pageSize ) { $ pageSize = intval ( $ pageSize ) ; $ offset = ( $ page - 1 ) * $ pageSize ; $ position = $ pageSize * $ page ; if ( null !== $ limit && $ position >= $ limit ) { $ pageSize = $ limit - $ offset ; $ loadLimit = $ pageSize ; } else { $ loadLimit = $ pageSize + 1 ; } return $ this -> contentQueryExecutor -> execute ( $ options [ 'webspaceKey' ] , [ $ options [ 'locale' ] ] , $ this -> contentQueryBuilder , true , - 1 , $ loadLimit , $ offset ) ; }
Load paginated data .
11,458
public function handlePreRemove ( RemoveEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ this -> supports ( $ document ) ) { return ; } $ event = $ this -> getDeleteEvent ( $ document ) ; $ this -> deleteEvents [ spl_object_hash ( $ document ) ] = $ event ; $ this -> eventDispatcher -> dispatch ( ContentEvents :: NODE_PRE_DELETE , $ event ) ; }
Dispatches the deprecated pre remove event .
11,459
public function handlePostRemove ( RemoveEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ this -> supports ( $ document ) ) { return ; } $ oid = spl_object_hash ( $ document ) ; $ event = $ this -> deleteEvents [ $ oid ] ; $ this -> eventDispatcher -> dispatch ( ContentEvents :: NODE_POST_DELETE , $ event ) ; unset ( $ this -> deleteEvents [ $ oid ] ) ; }
Dispatches the deprected post remove event .
11,460
public function handlePersist ( PersistEvent $ event ) { if ( ! $ this -> supports ( $ event -> getDocument ( ) ) ) { return ; } $ this -> persistEvents [ ] = $ event ; }
Saves all persisted documents to dispatch the deprecated post save event later when flushed .
11,461
public function handleFlush ( FlushEvent $ event ) { foreach ( $ this -> persistEvents as $ persistEvent ) { $ document = $ persistEvent -> getDocument ( ) ; $ structure = $ this -> documentToStructure ( $ document ) ; $ event = new ContentNodeEvent ( $ this -> documentInspector -> getNode ( $ document ) , $ structure ) ; $ this -> eventDispatcher -> dispatch ( ContentEvents :: NODE_POST_SAVE , $ event ) ; } $ this -> persistEvents = [ ] ; }
Dispatches the deprecated post save event for every persisted document .
11,462
public function addEmail ( \ Sulu \ Bundle \ ContactBundle \ Entity \ Email $ emails ) { $ this -> emails [ ] = $ emails ; return $ this ; }
Add emails .
11,463
public function removeEmail ( \ Sulu \ Bundle \ ContactBundle \ Entity \ Email $ emails ) { $ this -> emails -> removeElement ( $ emails ) ; }
Remove emails .
11,464
protected function loadStructureTags ( $ path , $ xpath ) { $ result = [ ] ; foreach ( $ xpath -> query ( $ path ) as $ node ) { $ tag = [ 'name' => null , 'attributes' => [ ] , ] ; foreach ( $ node -> attributes as $ key => $ attr ) { if ( in_array ( $ key , [ 'name' ] ) ) { $ tag [ $ key ] = $ attr -> value ; } else { $ tag [ 'attributes' ] [ $ key ] = $ attr -> value ; } } if ( ! isset ( $ tag [ 'name' ] ) ) { throw new \ InvalidArgumentException ( 'Tag does not have a name in template definition' ) ; } $ result [ ] = $ tag ; } return $ result ; }
Loads the tags for the structure .
11,465
protected function loadStructureAreas ( $ path , $ xpath ) { $ result = [ ] ; foreach ( $ xpath -> query ( $ path ) as $ node ) { $ area = [ ] ; foreach ( $ node -> attributes as $ key => $ attr ) { if ( in_array ( $ key , [ 'key' ] ) ) { $ area [ $ key ] = $ attr -> value ; } else { $ area [ 'attributes' ] [ $ key ] = $ attr -> value ; } } $ meta = $ this -> loadMeta ( 'x:meta/x:*' , $ xpath , $ node ) ; $ area [ 'title' ] = $ meta [ 'title' ] ; if ( ! isset ( $ area [ 'key' ] ) ) { throw new \ InvalidArgumentException ( 'Zone does not have a key in the attributes' ) ; } $ result [ ] = $ area ; } return $ result ; }
Loads the areas for the structure .
11,466
private function getSystem ( ) { $ system = $ this -> suluSystem ; $ request = $ this -> requestStack -> getCurrentRequest ( ) ; if ( null !== $ request && $ request -> attributes -> has ( '_sulu' ) && null !== ( $ webspace = $ request -> attributes -> get ( '_sulu' ) -> getAttribute ( 'webspace' ) ) && null !== ( $ security = $ webspace -> getSecurity ( ) ) ) { $ system = $ security -> getSystem ( ) ; } return $ system ; }
Returns the required system for the current request .
11,467
private function iterateRouteNodes ( NodeInterface $ node , $ callback , $ webspaceKey , $ languageCode , $ segmentKey = null ) { if ( $ node -> isNew ( ) ) { return null ; } $ routePath = $ this -> sessionManager -> getRoutePath ( $ webspaceKey , $ languageCode ) ; foreach ( $ node -> getReferences ( 'sulu:content' ) as $ ref ) { if ( $ ref instanceof \ PHPCR \ PropertyInterface ) { $ routeNode = $ ref -> getParent ( ) ; if ( 0 !== strpos ( $ routeNode -> getPath ( ) , $ routePath ) ) { continue ; } $ resourceLocator = $ this -> getResourceLocator ( $ ref -> getParent ( ) -> getPath ( ) , $ webspaceKey , $ languageCode , $ segmentKey ) ; $ result = $ callback ( $ resourceLocator , $ routeNode ) ; if ( false !== $ result ) { return $ result ; } } } return null ; }
Iterates over all route nodes assigned by the given node and executes the callback on it .
11,468
private function getWebspaceRouteNode ( $ webspaceKey , $ languageCode , $ segmentKey ) { return $ this -> sessionManager -> getRouteNode ( $ webspaceKey , $ languageCode , $ segmentKey ) ; }
Returns base node of routes from phpcr .
11,469
private function getWebspaceRouteNodeBasePath ( $ webspaceKey , $ languageCode , $ segmentKey ) { return $ this -> sessionManager -> getRoutePath ( $ webspaceKey , $ languageCode , $ segmentKey ) ; }
Returns base path of routes from phpcr .
11,470
private function getPath ( $ relPath , $ webspaceKey , $ languageCode , $ segmentKey ) { $ basePath = $ this -> getWebspaceRouteNodeBasePath ( $ webspaceKey , $ languageCode , $ segmentKey ) ; return '/' . ltrim ( $ basePath , '/' ) . ( '' !== $ relPath ? '/' . ltrim ( $ relPath , '/' ) : '' ) ; }
Returns the abspath .
11,471
private function getResourceLocator ( $ path , $ webspaceKey , $ languageCode , $ segmentKey ) { $ basePath = $ this -> getWebspaceRouteNodeBasePath ( $ webspaceKey , $ languageCode , $ segmentKey ) ; if ( $ path === $ basePath ) { return '/' ; } if ( false !== strpos ( $ path , $ basePath . '/' ) ) { $ result = str_replace ( $ basePath . '/' , '/' , $ path ) ; if ( 0 === strpos ( $ result , '/' ) ) { return $ result ; } } return false ; }
Returns resource - locator .
11,472
public function handleMetadataLoad ( MetadataLoadEvent $ event ) { $ metadata = $ event -> getMetadata ( ) ; if ( false === $ metadata -> getReflectionClass ( ) -> isSubclassOf ( RobotBehavior :: class ) ) { return ; } $ metadata -> addFieldMapping ( 'noFollow' , [ 'encoding' => 'system' , 'property' => 'noFollow' , ] ) ; $ metadata -> addFieldMapping ( 'noIndex' , [ 'encoding' => 'system' , 'property' => 'noIndex' , ] ) ; }
Append mapping for robot fields .
11,473
private function convertPdfToImage ( $ resource ) { $ temporaryFilePath = $ this -> createTemporaryFile ( $ resource ) ; $ command = $ this -> ghostScriptPath . ' -dNOPAUSE -sDEVICE=jpeg -dFirstPage=1 -dLastPage=1 -sOutputFile=' . $ temporaryFilePath . ' ' . '-dJPEGQ=100 -r300x300 -q ' . $ temporaryFilePath . ' -c quit 2> /dev/null' ; shell_exec ( $ command ) ; $ output = file_get_contents ( $ temporaryFilePath ) ; unlink ( $ temporaryFilePath ) ; if ( ! $ output ) { throw new GhostScriptNotFoundException ( 'Ghostscript was not found at "' . $ this -> ghostScriptPath . '"' ) ; } return $ this -> createTemporaryResource ( $ output ) ; }
Converts the first page of pdf to an image using ghostscript .
11,474
private function convertPsdToImage ( $ resource ) { $ temporaryFilePath = $ this -> createTemporaryFile ( $ resource ) ; try { $ image = $ this -> imagine -> open ( $ temporaryFilePath ) ; $ image = $ image -> layers ( ) [ 0 ] ; unlink ( $ temporaryFilePath ) ; return $ this -> createTemporaryResource ( $ image -> get ( 'png' ) ) ; } catch ( RuntimeException $ e ) { unlink ( $ temporaryFilePath ) ; throw new InvalidMimeTypeForPreviewException ( 'image/vnd.adobe.photoshop' ) ; } }
Converts a PSD to a png using imagine . Only works with Imagick and not with GD .
11,475
private function convertVideoToImage ( $ resource ) { $ temporaryFilePath = $ this -> createTemporaryFile ( $ resource ) ; $ this -> videoThumbnail -> generate ( $ temporaryFilePath , '00:00:02:01' , $ temporaryFilePath ) ; $ extractedImage = file_get_contents ( $ temporaryFilePath ) ; unlink ( $ temporaryFilePath ) ; return $ this -> createTemporaryResource ( $ extractedImage ) ; }
Converts one frame of a video to an image using FFMPEG .
11,476
private function createTemporaryResource ( string $ content ) { $ tempResource = fopen ( 'php://memory' , 'r+' ) ; fwrite ( $ tempResource , $ content ) ; rewind ( $ tempResource ) ; return $ tempResource ; }
Create temporary resource which will removed on fclose or end of process .
11,477
private function createTemporaryFile ( $ resource ) { $ path = tempnam ( sys_get_temp_dir ( ) , 'media' ) ; $ tempResource = fopen ( $ path , 'w' ) ; stream_copy_to_stream ( $ resource , $ tempResource ) ; return $ path ; }
Returns the path to a temporary file containing the given content .
11,478
private function doWrite ( NodeInterface $ node , PropertyInterface $ property , $ userId , $ webspaceKey , $ languageCode , $ segmentKey , $ isImport = false ) { if ( $ property -> getIsBlock ( ) ) { $ blockProperty = $ property ; while ( ! ( $ blockProperty instanceof BlockPropertyInterface ) ) { $ blockProperty = $ blockProperty -> getProperty ( ) ; } $ data = $ blockProperty -> getValue ( ) ; if ( ! $ blockProperty -> getIsMultiple ( ) ) { $ data = [ $ data ] ; } $ data = array_filter ( $ data ) ; $ len = count ( $ data ) ; $ typeProperty = new Property ( 'type' , '' , 'text_line' ) ; $ lengthProperty = new Property ( 'length' , '' , 'text_line' ) ; $ lengthProperty -> setValue ( $ len ) ; $ contentType = $ this -> contentTypeManager -> get ( $ lengthProperty -> getContentTypeName ( ) ) ; $ contentType -> write ( $ node , new BlockPropertyWrapper ( $ lengthProperty , $ property ) , $ userId , $ webspaceKey , $ languageCode , $ segmentKey ) ; for ( $ i = 0 ; $ i < $ len ; ++ $ i ) { $ blockPropertyType = $ blockProperty -> getProperties ( $ i ) ; $ this -> writeProperty ( $ typeProperty , $ property , $ blockPropertyType -> getName ( ) , $ i , $ node , $ userId , $ webspaceKey , $ languageCode , $ segmentKey , $ isImport ) ; foreach ( $ blockProperty -> getProperties ( $ i ) -> getChildProperties ( ) as $ subProperty ) { $ this -> writeProperty ( $ subProperty , $ property , $ subProperty -> getValue ( ) , $ i , $ node , $ userId , $ webspaceKey , $ languageCode , $ segmentKey , $ isImport ) ; } } } else { throw new UnexpectedPropertyType ( $ property , $ this ) ; } }
Save the value from given property .
11,479
private function writeProperty ( PropertyInterface $ property , PropertyInterface $ blockProperty , $ value , $ index , NodeInterface $ node , $ userId , $ webspaceKey , $ languageCode , $ segmentKey , $ isImport = false ) { $ contentType = $ this -> contentTypeManager -> get ( $ property -> getContentTypeName ( ) ) ; $ blockPropertyWrapper = new BlockPropertyWrapper ( $ property , $ blockProperty , $ index ) ; $ blockPropertyWrapper -> setValue ( $ value ) ; if ( $ isImport && $ contentType instanceof ContentTypeExportInterface ) { return $ contentType -> importData ( new SuluNode ( $ node ) , $ blockPropertyWrapper , $ value , $ userId , $ webspaceKey , $ languageCode , $ segmentKey ) ; } $ contentType -> write ( new SuluNode ( $ node ) , $ blockPropertyWrapper , $ userId , $ webspaceKey , $ languageCode , $ segmentKey ) ; }
write a property to node .
11,480
private function configureMapManager ( $ config , ContainerBuilder $ container ) { $ mapManager = $ container -> getDefinition ( 'sulu_location.map_manager' ) ; foreach ( $ config [ 'enabled_providers' ] as $ enabledProviderName ) { $ providerConfig = $ config [ 'providers' ] [ $ enabledProviderName ] ; $ mapManager -> addMethodCall ( 'registerProvider' , [ $ enabledProviderName , $ providerConfig , ] ) ; } foreach ( $ config [ 'geolocators' ] as $ geoLocatorName => $ geoLocatorOptions ) { $ mapManager -> addMethodCall ( 'registerGeolocator' , [ $ geoLocatorName , $ geoLocatorOptions , ] ) ; } $ mapManager -> addMethodCall ( 'setDefaultProviderName' , [ $ config [ 'default_provider' ] ] ) ; }
Configure the map manager - register the providers and geolocators with the map manager class .
11,481
private function configureGeolocators ( $ config , $ container ) { $ geolocatorName = $ config [ 'geolocator' ] ; $ container -> setParameter ( 'sulu_location.geolocator.name' , $ geolocatorName ) ; $ nominatim = function ( $ config , $ container ) { $ endpoint = $ config [ 'geolocators' ] [ 'nominatim' ] [ 'endpoint' ] ; $ container -> setParameter ( 'sulu_location.geolocator.service.nominatim.endpoint' , $ endpoint ) ; } ; $ google = function ( $ config , $ container ) { $ apiKey = $ config [ 'geolocators' ] [ 'google' ] [ 'api_key' ] ; $ container -> setParameter ( 'sulu_location.geolocator.service.google.api_key' , $ apiKey ) ; } ; $ nominatim ( $ config , $ container ) ; $ google ( $ config , $ container ) ; }
Configure the geolocator services .
11,482
protected function updateLastLogin ( $ user ) { if ( $ user instanceof BaseUser ) { $ user -> setLastLogin ( new \ DateTime ( ) ) ; $ this -> entityManager -> flush ( ) ; } }
Update the users last login .
11,483
public function handleCreate ( QueryCreateEvent $ event ) { $ innerQuery = $ event -> getInnerQuery ( ) ; if ( is_string ( $ innerQuery ) ) { $ phpcrQuery = $ this -> getQueryManager ( ) -> createQuery ( $ innerQuery , QueryInterface :: JCR_SQL2 ) ; } elseif ( $ innerQuery instanceof QueryInterface ) { $ phpcrQuery = $ innerQuery ; } else { throw new \ InvalidArgumentException ( sprintf ( 'Expected inner query to be either a string or a PHPCR query object, got: "%s"' , is_object ( $ innerQuery ) ? get_class ( $ innerQuery ) : gettype ( $ innerQuery ) ) ) ; } $ event -> setQuery ( new Query ( $ phpcrQuery , $ this -> eventDispatcher , $ event -> getLocale ( ) , $ event -> getOptions ( ) , $ event -> getPrimarySelector ( ) ) ) ; }
Create a new Sulu Query object .
11,484
public function handleQueryExecute ( QueryExecuteEvent $ event ) { $ query = $ event -> getQuery ( ) ; $ locale = $ query -> getLocale ( ) ; $ phpcrResult = $ query -> getPhpcrQuery ( ) -> execute ( ) ; $ event -> setResult ( new QueryResultCollection ( $ phpcrResult , $ this -> eventDispatcher , $ locale , $ event -> getOptions ( ) ) ) ; }
Handle query execution .
11,485
private function addSorting ( $ qb , $ sorting , $ prefix = 'u' ) { foreach ( $ sorting as $ k => $ d ) { $ qb -> addOrderBy ( $ prefix . '.' . $ k , $ d ) ; } return $ qb ; }
Add sorting to querybuilder .
11,486
private function addPagination ( $ qb , $ offset , $ limit ) { $ qb -> setFirstResult ( $ offset ) ; $ qb -> setMaxResults ( $ limit ) ; return $ qb ; }
add pagination to querybuilder .
11,487
private function addWhere ( $ qb , $ where , $ prefix = '' ) { $ prefix = '' !== $ prefix ? $ prefix . '.' : '' ; $ and = $ qb -> expr ( ) -> andX ( ) ; foreach ( $ where as $ k => $ v ) { $ and -> add ( $ qb -> expr ( ) -> eq ( $ prefix . $ k , "'" . $ v . "'" ) ) ; } $ qb -> where ( $ and ) ; return $ qb ; }
add where to querybuilder .
11,488
private function getValue ( PropertyInterface $ property ) { $ default = [ 'presentAs' => null , 'items' => [ ] ] ; if ( ! is_array ( $ property -> getValue ( ) ) ) { return $ default ; } return array_merge ( $ default , $ property -> getValue ( ) ) ; }
Returns property - value merged with defaults .
11,489
public static function getUserClassName ( $ className ) { if ( null === self :: $ inflector ) { static :: $ inflector = new ProxyManagerClassNameInflector ( '' ) ; } return static :: $ inflector -> getUserClassName ( $ className ) ; }
Return the real class name if the given class name is a proxy class name .
11,490
public function cgetAction ( Request $ request ) { $ ids = array_filter ( explode ( ',' , $ request -> get ( 'ids' , '' ) ) ) ; $ result = $ this -> getCustomerManager ( ) -> findByIds ( $ ids ) ; $ list = new CollectionRepresentation ( $ result , self :: $ entityKey ) ; $ view = $ this -> view ( $ list , 200 ) ; return $ this -> handleView ( $ view ) ; }
Returns list of contacts and organizations .
11,491
public function addUrl ( Url $ url ) { $ this -> urls [ ] = $ url ; $ url -> setEnvironment ( $ this -> getType ( ) ) ; if ( $ url -> isMain ( ) || ! $ this -> mainUrl ) { $ this -> setMainUrl ( $ url ) ; } }
Adds a new url to this environment .
11,492
private function setMainUrl ( Url $ url ) { if ( null !== $ this -> mainUrl ) { $ this -> mainUrl -> setMain ( false ) ; } $ this -> mainUrl = $ url ; $ this -> mainUrl -> setMain ( true ) ; }
Sets the main url .
11,493
public function handleHydrate ( AbstractMappingEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ this -> supports ( $ document ) ) { return ; } $ node = $ event -> getNode ( ) ; $ property = $ this -> getResourceSegmentProperty ( $ document ) ; if ( ! $ property ) { return ; } $ locale = $ this -> documentInspector -> getOriginalLocale ( $ document ) ; $ segment = $ node -> getPropertyValueWithDefault ( $ this -> encoder -> localizedSystemName ( $ property -> getName ( ) , $ locale ) , '' ) ; $ document -> setResourceSegment ( $ segment ) ; }
Sets the ResourceSegment of the document .
11,494
public function handlePersistDocument ( PersistEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ this -> supports ( $ document ) ) { return ; } $ property = $ this -> getResourceSegmentProperty ( $ document ) ; if ( $ property ) { $ this -> persistDocument ( $ document , $ property ) ; } }
Sets the ResourceSegment on the Structure .
11,495
public function handlePersistRoute ( PublishEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ this -> supports ( $ document ) ) { return ; } if ( ! $ event -> getLocale ( ) ) { return ; } if ( $ document instanceof HomeDocument ) { return ; } if ( $ document instanceof RedirectTypeBehavior && RedirectType :: NONE !== $ document -> getRedirectType ( ) ) { return ; } $ this -> persistRoute ( $ document ) ; }
Creates or updates the route for the document .
11,496
public function updateMovedDocument ( MoveEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ document instanceof ResourceSegmentBehavior ) { return ; } $ webspaceKey = $ this -> documentInspector -> getWebspace ( $ event -> getDocument ( ) ) ; if ( ! $ webspaceKey ) { return ; } $ resourceLocatorStrategy = $ this -> resourceLocatorStrategyPool -> getStrategyByWebspaceKey ( $ webspaceKey ) ; if ( ResourceLocatorStrategyInterface :: INPUT_TYPE_LEAF !== $ resourceLocatorStrategy -> getInputType ( ) ) { return ; } $ this -> updateRoute ( $ document , true ) ; }
Moves the routes for all localizations of the document in the event .
11,497
public function updateCopiedDocument ( CopyEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ document instanceof ResourceSegmentBehavior ) { return ; } $ this -> updateRoute ( $ this -> documentManager -> find ( $ event -> getCopiedPath ( ) , $ this -> documentInspector -> getLocale ( $ document ) ) , false ) ; }
Copy the routes for all localization of the document in the event .
11,498
private function getResourceSegmentProperty ( $ document ) { $ structure = $ this -> documentInspector -> getStructureMetadata ( $ document ) ; if ( ! $ structure ) { return ; } $ property = $ structure -> getPropertyByTagName ( 'sulu.rlp' ) ; if ( ! $ property ) { throw new \ RuntimeException ( sprintf ( 'Structure "%s" does not have a "sulu.rlp" tag which is required for documents implementing the ' . 'ResourceSegmentBehavior. In "%s"' , $ structure -> name , $ structure -> resource ) ) ; } return $ property ; }
Returns the property of the document s structure containing the ResourceSegment .
11,499
private function persistDocument ( ResourceSegmentBehavior $ document , PropertyMetadata $ property ) { $ document -> getStructure ( ) -> getProperty ( $ property -> getName ( ) ) -> setValue ( $ document -> getResourceSegment ( ) ) ; }
Sets the ResourceSegment to the given property of the given document .