idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
11,600
public function setOptions ( $ options ) { $ this -> options = [ 'config_dir' => null , 'cache_dir' => null , 'debug' => false , 'cache_class' => 'WebspaceCollectionCache' , 'base_class' => 'WebspaceCollection' , ] ; $ this -> options = array_merge ( $ this -> options , $ options ) ; }
Sets the options for the manager .
11,601
protected function isFromDomain ( $ url , $ domain ) { if ( ! $ domain ) { return true ; } $ parsedUrl = parse_url ( $ url ) ; if ( isset ( $ parsedUrl [ 'host' ] ) && ( $ parsedUrl [ 'host' ] == $ domain || fnmatch ( '*.' . $ domain , $ parsedUrl [ 'host' ] ) ) ) { return true ; } return false ; }
Url is from domain .
11,602
private function createResourceLocatorUrl ( $ scheme , $ portalUrl , $ resourceLocator ) { if ( false !== strpos ( $ portalUrl , '/' ) ) { $ resourceLocator = rtrim ( $ resourceLocator , '/' ) ; } return rtrim ( sprintf ( '%s://%s' , $ scheme , $ portalUrl ) , '/' ) . $ resourceLocator ; }
Return a valid resource locator url .
11,603
protected function loadTemplateAttributes ( $ resource , \ DOMXPath $ xpath , $ type ) { if ( 'page' === $ type || 'home' === $ type ) { $ result = [ 'key' => $ this -> getValueFromXPath ( '/x:template/x:key' , $ xpath ) , 'view' => $ this -> getValueFromXPath ( '/x:template/x:view' , $ xpath ) , 'controller' => $ this -> getValueFromXPath ( '/x:template/x:controller' , $ xpath ) , 'internal' => $ this -> getValueFromXPath ( '/x:template/x:internal' , $ xpath ) , 'cacheLifetime' => $ this -> loadCacheLifetime ( '/x:template/x:cacheLifetime' , $ xpath ) , 'tags' => $ this -> loadStructureTags ( '/x:template/x:tag' , $ xpath ) , 'areas' => $ this -> loadStructureAreas ( '/x:template/x:areas/x:area' , $ xpath ) , 'meta' => $ this -> loadMeta ( '/x:template/x:meta/x:*' , $ xpath ) , ] ; $ result = array_filter ( $ result , function ( $ value ) { return null !== $ value ; } ) ; foreach ( [ 'key' , 'view' , 'controller' , 'cacheLifetime' ] as $ requiredProperty ) { if ( ! isset ( $ result [ $ requiredProperty ] ) ) { throw new InvalidXmlException ( $ type , sprintf ( 'Property "%s" is required in XML template file "%s"' , $ requiredProperty , $ resource ) ) ; } } } else { $ result = [ 'key' => $ this -> getValueFromXPath ( '/x:template/x:key' , $ xpath ) , 'view' => $ this -> getValueFromXPath ( '/x:template/x:view' , $ xpath ) , 'controller' => $ this -> getValueFromXPath ( '/x:template/x:controller' , $ xpath ) , 'cacheLifetime' => $ this -> loadCacheLifetime ( '/x:template/x:cacheLifetime' , $ xpath ) , 'tags' => $ this -> loadStructureTags ( '/x:template/x:tag' , $ xpath ) , 'areas' => $ this -> loadStructureAreas ( '/x:template/x:areas/x:area' , $ xpath ) , 'meta' => $ this -> loadMeta ( '/x:template/x:meta/x:*' , $ xpath ) , ] ; $ result = array_filter ( $ result , function ( $ value ) { return null !== $ value ; } ) ; if ( count ( $ result ) < 1 ) { throw new InvalidXmlException ( $ result [ 'key' ] ) ; } } return $ result ; }
Load template attributes .
11,604
private function loadCacheLifetime ( $ path , \ DOMXPath $ xpath ) { $ nodeList = $ xpath -> query ( $ path ) ; if ( ! $ nodeList -> length ) { return [ 'type' => CacheLifetimeResolverInterface :: TYPE_SECONDS , 'value' => 0 , ] ; } $ node = $ nodeList -> item ( 0 ) ; $ type = $ node -> getAttribute ( 'type' ) ; if ( '' === $ type ) { $ type = CacheLifetimeResolverInterface :: TYPE_SECONDS ; } $ value = $ node -> nodeValue ; if ( ! $ this -> cacheLifetimeResolver -> supports ( $ type , $ value ) ) { throw new \ InvalidArgumentException ( sprintf ( 'CacheLifetime "%s" with type "%s" not supported.' , $ value , $ type ) ) ; } return [ 'type' => $ type , 'value' => $ value , ] ; }
Load cache lifetime metadata .
11,605
public function getStatement ( QueryBuilder $ queryBuilder ) { $ paramName1 = $ this -> getFieldName ( ) . $ this -> getUniqueId ( ) ; $ paramName2 = $ this -> getFieldName ( ) . $ this -> getUniqueId ( ) ; $ queryBuilder -> setParameter ( $ paramName1 , $ this -> getStart ( ) ) ; $ queryBuilder -> setParameter ( $ paramName2 , $ this -> getEnd ( ) ) ; return $ this -> field -> getSelect ( ) . ' BETWEEN :' . $ paramName1 . ' AND :' . $ paramName2 ; }
Returns a statement for an expression .
11,606
public function addFieldMapping ( $ name , $ mapping ) { $ mapping = array_merge ( [ 'encoding' => 'content' , 'property' => $ name , 'type' => null , 'mapped' => true , 'multiple' => false , 'default' => null , ] , $ mapping ) ; $ this -> fieldMappings [ $ name ] = $ mapping ; }
Add a field mapping for field with given name for example .
11,607
public function getReflectionClass ( ) { if ( $ this -> reflection ) { return $ this -> reflection ; } if ( ! $ this -> class ) { throw new \ InvalidArgumentException ( 'Cannot retrieve ReflectionClass on metadata which has no class attribute' ) ; } $ this -> reflection = new \ ReflectionClass ( $ this -> class ) ; return $ this -> reflection ; }
Returns reflection - class .
11,608
public function execute ( array $ fixtures , $ purge = true , $ initialize = true , OutputInterface $ output = null ) { $ output = $ output ? : new NullOutput ( ) ; if ( true === $ initialize ) { $ output -> writeln ( '<comment>Initializing repository</comment>' ) ; $ this -> initializer -> initialize ( $ output , $ purge ) ; } $ output -> writeln ( '<comment>Loading fixtures</comment>' ) ; foreach ( $ fixtures as $ fixture ) { $ output -> writeln ( sprintf ( ' - %s<info>loading "</info>%s<info>"</info>' , $ fixture instanceof OrderedFixtureInterface ? '[' . $ fixture -> getOrder ( ) . ']' : '' , get_class ( $ fixture ) ) ) ; $ fixture -> load ( $ this -> documentManager ) ; $ this -> documentManager -> clear ( ) ; } }
Load the given fixture classes .
11,609
public function onKernelRequest ( GetResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; $ this -> requestAnalyzer -> analyze ( $ request ) ; $ this -> baseRouteListener -> onKernelRequest ( $ event ) ; if ( false !== $ request -> attributes -> get ( static :: REQUEST_ANALYZER , true ) ) { $ this -> requestAnalyzer -> validate ( $ request ) ; } }
Analyzes the request before passing the event to the default RouterListener from symfony and validates the result afterwards .
11,610
public function getParent ( ) { $ account = $ this -> entity -> getParent ( ) ; if ( $ account ) { return new self ( $ account , $ this -> locale ) ; } return ; }
Get parent .
11,611
public function getSocialMediaProfiles ( ) { $ socialMediaProfiles = [ ] ; if ( $ this -> entity -> getSocialMediaProfiles ( ) ) { foreach ( $ this -> entity -> getSocialMediaProfiles ( ) as $ socialMediaProfile ) { $ socialMediaProfiles [ ] = $ socialMediaProfile ; } } return $ socialMediaProfiles ; }
Get social media profiles .
11,612
public function getBankAccounts ( ) { $ bankAccounts = [ ] ; if ( $ this -> entity -> getBankAccounts ( ) ) { foreach ( $ this -> entity -> getBankAccounts ( ) as $ bankAccount ) { $ bankAccounts [ ] = new BankAccount ( $ bankAccount ) ; } } return $ bankAccounts ; }
Get bankAccounts .
11,613
public function getAccountContacts ( ) { $ accountContacts = [ ] ; if ( $ this -> entity -> getAccountContacts ( ) ) { foreach ( $ this -> entity -> getAccountContacts ( ) as $ AccountContact ) { $ accountContacts [ ] = new AccountContact ( $ AccountContact , $ this -> locale ) ; } } return $ accountContacts ; }
Get accountContacts .
11,614
public function getMainContact ( ) { if ( $ this -> entity -> getMainContact ( ) ) { return new Contact ( $ this -> entity -> getMainContact ( ) , $ this -> locale ) ; } }
Get mainContact .
11,615
public function getAccountAddresses ( ) { $ accountAddresses = [ ] ; if ( $ this -> entity -> getAccountAddresses ( ) ) { foreach ( $ this -> entity -> getAccountAddresses ( ) as $ adr ) { $ accountAddress [ ] = new AccountAddress ( $ adr ) ; } } return $ accountAddresses ; }
Get accountAddresses .
11,616
public function getAddresses ( ) { $ accountAddresses = $ this -> entity -> getAccountAddresses ( ) ; $ addresses = [ ] ; if ( ! is_null ( $ accountAddresses ) ) { foreach ( $ accountAddresses as $ accountAddress ) { $ address = $ accountAddress -> getAddress ( ) ; $ address -> setPrimaryAddress ( $ accountAddress -> getMain ( ) ) ; $ addresses [ ] = new Address ( $ address , $ this -> locale ) ; } } return $ addresses ; }
returns addresses .
11,617
public function getMainAddress ( ) { $ accountAddresses = $ this -> entity -> getAccountAddresses ( ) ; if ( ! is_null ( $ accountAddresses ) ) { foreach ( $ accountAddresses as $ accountAddress ) { if ( $ accountAddress -> getMain ( ) ) { return $ accountAddress -> getAddress ( ) ; } } } return ; }
Returns the main address .
11,618
public function getLogo ( ) { if ( $ this -> logo ) { return [ 'id' => $ this -> logo -> getId ( ) , 'url' => $ this -> logo -> getUrl ( ) , 'thumbnails' => $ this -> logo -> getFormats ( ) , ] ; } return ; }
Get the accounts logo and return the array of different formats .
11,619
public function cleanup ( $ dirty , $ languageCode = null ) { $ replacers = $ this -> replacers [ 'default' ] ; if ( null !== $ languageCode ) { $ replacers = array_merge ( $ replacers , ( isset ( $ this -> replacers [ $ languageCode ] ) ? $ this -> replacers [ $ languageCode ] : [ ] ) ) ; } if ( count ( $ replacers ) > 0 ) { foreach ( $ replacers as $ key => $ value ) { $ dirty = str_replace ( $ key , $ value , $ dirty ) ; } } $ clean = strtolower ( $ dirty ) ; $ clean = str_replace ( '%2F' , '/' , urlencode ( preg_replace ( '/([^A-za-z0-9 -_\/])/' , '' , $ clean ) ) ) ; $ clean = preg_replace ( '/([-]+)/' , '-' , $ clean ) ; $ clean = preg_replace ( '/\/[-]+/' , '/' , $ clean ) ; $ clean = preg_replace ( '/^([-])/' , '' , $ clean ) ; $ clean = preg_replace ( '/([-])$/' , '' , $ clean ) ; $ clean = str_replace ( '//' , '/' , $ clean ) ; return $ clean ; }
returns a clean string .
11,620
public function getProperty ( $ name ) { if ( ! isset ( $ this -> properties [ $ name ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Unknown model property "%s", in structure "%s". Known model properties: "%s". Loaded from "%s"' , $ name , $ this -> getName ( ) , implode ( '", "' , array_keys ( $ this -> properties ) ) , $ this -> resource ) ) ; } return $ this -> properties [ $ name ] ; }
Return a model property .
11,621
public function getPropertyByTagName ( $ tagName , $ highest = true ) { $ properties = $ this -> getPropertiesByTagName ( $ tagName ) ; if ( ! $ properties ) { throw new \ InvalidArgumentException ( sprintf ( 'No property with tag "%s" exists. In structure "%s" loaded from "%s"' , $ tagName , $ this -> name , $ this -> resource ) ) ; } return reset ( $ properties ) ; }
Return true if the structure contains a property with the given tag name .
11,622
public function getPropertiesByTagName ( $ tagName ) { $ properties = [ ] ; foreach ( $ this -> properties as $ property ) { foreach ( $ property -> tags as $ tag ) { if ( $ tag [ 'name' ] == $ tagName ) { $ properties [ $ property -> name ] = $ property ; } } } return $ properties ; }
Return all properties with the given tag name .
11,623
private function getMedia ( Document $ document , $ field ) { $ images = json_decode ( $ document -> getField ( $ field ) -> getValue ( ) , true ) ; if ( ! array_key_exists ( 'ids' , $ images ) || 0 === count ( $ images [ 'ids' ] ) ) { return ; } return $ images [ 'ids' ] [ 0 ] ; }
Returns media - id .
11,624
public function findUserByUsername ( $ username ) { $ qb = $ this -> createQueryBuilder ( 'user' ) -> where ( 'user.username=:username' ) ; $ query = $ qb -> getQuery ( ) ; $ query -> setParameter ( 'username' , $ username ) ; return $ query -> getSingleResult ( ) ; }
Finds a user for the given username .
11,625
public function findAllUsersByRoleId ( $ roleId ) { $ qb = $ this -> createQueryBuilder ( 'user' ) -> leftJoin ( 'user.userRoles' , 'userRole' ) -> leftJoin ( 'userRole.role' , 'role' ) -> where ( 'role=:roleId' ) ; $ query = $ qb -> getQuery ( ) ; $ query -> setParameter ( 'roleId' , $ roleId ) ; return $ query -> getResult ( ) ; }
Finds all users for the role with the given id .
11,626
public function findUserByEmail ( $ email ) { $ qb = $ this -> createQueryBuilder ( 'user' ) -> where ( 'user.email=:email' ) ; $ query = $ qb -> getQuery ( ) ; $ query -> setParameter ( 'email' , $ email ) ; return $ query -> getSingleResult ( ) ; }
Finds a user for a given email .
11,627
public function findUserByToken ( $ token ) { $ qb = $ this -> createQueryBuilder ( 'user' ) -> where ( 'user.passwordResetToken=:token' ) ; $ query = $ qb -> getQuery ( ) ; $ query -> setParameter ( 'token' , $ token ) ; return $ query -> getSingleResult ( ) ; }
Finds a user for a given password - reset - token .
11,628
public function findUserBySystem ( $ system ) { $ queryBuilder = $ this -> createQueryBuilder ( 'user' ) -> select ( 'user' , 'contact' ) -> leftJoin ( 'user.userRoles' , 'userRoles' ) -> leftJoin ( 'user.contact' , 'contact' ) -> leftJoin ( 'userRoles.role' , 'role' ) -> where ( 'role.system = :system' ) ; $ query = $ queryBuilder -> getQuery ( ) ; $ query -> setParameter ( 'system' , $ system ) ; return $ query -> getResult ( ) ; }
Returns all users with the given system including their contacts .
11,629
public function searchAction ( Request $ request ) { $ queryString = $ request -> query -> get ( 'q' ) ; $ index = $ request -> query -> get ( 'index' , null ) ; $ locale = $ request -> query -> get ( 'locale' , null ) ; $ page = $ this -> listRestHelper -> getPage ( ) ; $ limit = $ this -> listRestHelper -> getLimit ( ) ; $ startTime = microtime ( true ) ; $ indexes = $ index ? [ $ index ] : $ this -> getAllowedIndexes ( ) ; $ query = $ this -> searchManager -> createSearch ( $ queryString ) ; if ( $ locale ) { $ query -> locale ( $ locale ) ; } $ query -> indexes ( $ indexes ) ; $ query -> setLimit ( $ limit ) ; $ time = microtime ( true ) - $ startTime ; $ adapter = new ArrayAdapter ( iterator_to_array ( $ query -> execute ( ) ) ) ; $ pager = new Pagerfanta ( $ adapter ) ; $ pager -> setMaxPerPage ( $ limit ) ; $ pager -> setCurrentPage ( $ page ) ; $ representation = new SearchResultRepresentation ( new CollectionRepresentation ( $ pager -> getCurrentPageResults ( ) , 'result' ) , 'sulu_search_search' , [ 'locale' => $ locale , 'query' => $ query , 'index' => $ index , ] , ( int ) $ page , ( int ) $ limit , $ pager -> getNbPages ( ) , 'page' , 'limit' , false , $ adapter -> getNbResults ( ) , $ this -> getIndexTotals ( $ adapter -> getArray ( ) ) , number_format ( $ time , 8 ) ) ; $ view = View :: create ( $ representation ) ; $ context = new Context ( ) ; $ context -> enableMaxDepth ( ) ; $ view -> setContext ( $ context ) ; return $ this -> viewHandler -> handle ( $ view ) ; }
Perform a search and return a JSON response .
11,630
public function indexesAction ( ) { return $ this -> viewHandler -> handle ( View :: create ( array_map ( function ( $ indexName ) { $ indexConfiguration = $ this -> indexConfigurationProvider -> getIndexConfiguration ( $ indexName ) ; return $ indexConfiguration ? : new IndexConfiguration ( $ indexName ) ; } , $ this -> getAllowedIndexes ( ) ) ) ) ; }
Return a JSON encoded scalar array of index names .
11,631
private function getIndexTotals ( $ hits ) { $ indexNames = $ this -> searchManager -> getIndexNames ( ) ; $ indexCount = array_combine ( $ indexNames , array_fill ( 0 , count ( $ indexNames ) , 0 ) ) ; foreach ( $ hits as $ hit ) { ++ $ indexCount [ $ hit -> getDocument ( ) -> getIndex ( ) ] ; } return $ indexCount ; }
Return the category totals for the search results .
11,632
public function addLocalization ( Localization $ localization ) { $ this -> localizations [ ] = $ localization ; if ( $ localization -> isDefault ( ) ) { $ this -> setDefaultLocalization ( $ localization ) ; } if ( $ localization -> isXDefault ( ) ) { $ this -> setXDefaultLocalization ( $ localization ) ; } }
Adds the given language to the portal .
11,633
public function setEnvironments ( array $ environments ) { $ this -> environments = [ ] ; foreach ( $ environments as $ environment ) { $ this -> addEnvironment ( $ environment ) ; } }
Sets the environments for this portal .
11,634
public function getEnvironment ( $ type ) { if ( ! isset ( $ this -> environments [ $ type ] ) ) { throw new EnvironmentNotFoundException ( $ this , $ type ) ; } return $ this -> environments [ $ type ] ; }
Returns the environment with the given type and throws an exception if the environment does not exist .
11,635
private function getLanguage ( Request $ request ) { $ locale = $ this -> getRequestParameter ( $ request , 'locale' , false , null ) ; if ( $ locale ) { return $ locale ; } return $ this -> getRequestParameter ( $ request , 'language' , true ) ; }
returns language code from request .
11,636
public function getAction ( Request $ request , $ id ) { if ( null !== $ request -> get ( 'fields' ) ) { return $ this -> getContent ( $ request , $ id ) ; } return $ this -> getSingleNode ( $ request , $ id ) ; }
returns a content item with given UUID as JSON String .
11,637
private function getContent ( Request $ request , $ id ) { $ properties = array_filter ( explode ( ',' , $ request -> get ( 'fields' , '' ) ) ) ; $ excludeGhosts = $ this -> getBooleanRequestParameter ( $ request , 'exclude-ghosts' , false , false ) ; $ excludeShadows = $ this -> getBooleanRequestParameter ( $ request , 'exclude-shadows' , false , false ) ; $ webspaceNodes = $ this -> getRequestParameter ( $ request , 'webspace-nodes' ) ; $ locale = $ this -> getRequestParameter ( $ request , 'language' , true ) ; $ webspaceKey = $ this -> getRequestParameter ( $ request , 'webspace' ) ; $ user = $ this -> getUser ( ) ; $ mapping = MappingBuilder :: create ( ) -> setHydrateGhost ( ! $ excludeGhosts ) -> setHydrateShadow ( ! $ excludeShadows ) -> setResolveConcreteLocales ( true ) -> addProperties ( $ properties ) -> getMapping ( ) ; $ data = $ this -> get ( 'sulu_page.content_repository' ) -> find ( $ id , $ locale , $ webspaceKey , $ mapping , $ user ) ; $ view = $ this -> view ( $ data ) ; return $ this -> handleView ( $ view ) ; }
Returns single content .
11,638
private function getTreeContent ( $ id , $ locale , $ webspaceKey , $ webspaceNodes , MappingInterface $ mapping , UserInterface $ user ) { if ( ! in_array ( $ webspaceNodes , [ static :: WEBSPACE_NODE_SINGLE , static :: WEBSPACE_NODES_ALL , null ] ) ) { throw new ParameterDataTypeException ( get_class ( $ this ) , 'webspace-nodes' ) ; } try { $ contents = $ this -> get ( 'sulu_page.content_repository' ) -> findParentsWithSiblingsByUuid ( $ id , $ locale , $ webspaceKey , $ mapping , $ user ) ; } catch ( ItemNotFoundException $ e ) { throw new EntityNotFoundException ( 'node' , $ id , $ e ) ; } if ( $ webspaceNodes === static :: WEBSPACE_NODES_ALL ) { $ contents = $ this -> getWebspaceNodes ( $ mapping , $ contents , $ locale , $ user ) ; } elseif ( $ webspaceNodes === static :: WEBSPACE_NODE_SINGLE ) { $ contents = $ this -> getWebspaceNode ( $ mapping , $ contents , $ webspaceKey , $ locale , $ user ) ; } $ view = $ this -> view ( new CollectionRepresentation ( $ contents , static :: $ relationName ) ) ; return $ this -> handleView ( $ view ) ; }
Returns tree response for given id .
11,639
private function getTreeForUuid ( Request $ request , $ id ) { $ language = $ this -> getLanguage ( $ request ) ; $ webspace = $ this -> getWebspace ( $ request , false ) ; $ excludeGhosts = $ this -> getBooleanRequestParameter ( $ request , 'exclude-ghosts' , false , false ) ; $ excludeShadows = $ this -> getBooleanRequestParameter ( $ request , 'exclude-shadows' , false , false ) ; try { if ( null !== $ id && '' !== $ id ) { $ result = $ this -> getRepository ( ) -> getNodesTree ( $ id , $ webspace , $ language , $ excludeGhosts , $ excludeShadows ) ; } elseif ( null !== $ webspace ) { $ result = $ this -> getRepository ( ) -> getWebspaceNode ( $ webspace , $ language ) ; } else { $ result = $ this -> getRepository ( ) -> getWebspaceNodes ( $ language ) ; } } catch ( DocumentNotFoundException $ ex ) { return $ this -> redirect ( $ this -> generateUrl ( 'get_nodes' , [ 'tree' => 'false' , 'depth' => 1 , 'language' => $ language , 'webspace' => $ webspace , 'exclude-ghosts' => $ excludeGhosts , ] ) ) ; } return $ this -> handleView ( $ this -> view ( $ result ) ) ; }
Returns a tree along the given path with the siblings of all nodes on the path . This functionality is required for preloading the content navigation .
11,640
private function getNodesByIds ( Request $ request , $ idString ) { $ language = $ this -> getLanguage ( $ request ) ; $ webspace = $ this -> getWebspace ( $ request , false ) ; $ result = $ this -> getRepository ( ) -> getNodesByIds ( preg_split ( '/[,]/' , $ idString , - 1 , PREG_SPLIT_NO_EMPTY ) , $ webspace , $ language ) ; return $ this -> handleView ( $ this -> view ( $ result ) ) ; }
Returns nodes by given ids .
11,641
public function indexAction ( Request $ request ) { $ language = $ this -> getLanguage ( $ request ) ; $ webspace = $ this -> getWebspace ( $ request ) ; $ result = $ this -> getRepository ( ) -> getIndexNode ( $ webspace , $ language ) ; return $ this -> handleView ( $ this -> view ( $ result ) ) ; }
returns a content item for startpage .
11,642
public function cgetAction ( Request $ request ) { if ( null !== $ request -> get ( 'fields' ) ) { return $ this -> cgetContent ( $ request ) ; } return $ this -> cgetNodes ( $ request ) ; }
returns all content items as JSON String .
11,643
public function cgetNodes ( Request $ request ) { $ tree = $ this -> getBooleanRequestParameter ( $ request , 'tree' , false , false ) ; $ ids = $ this -> getRequestParameter ( $ request , 'ids' ) ; if ( true === $ tree ) { return $ this -> getTreeForUuid ( $ request , $ this -> getRequestParameter ( $ request , 'id' , false , null ) ) ; } elseif ( null !== $ ids ) { return $ this -> getNodesByIds ( $ request , $ ids ) ; } $ language = $ this -> getLanguage ( $ request ) ; $ webspace = $ this -> getWebspace ( $ request ) ; $ excludeGhosts = $ this -> getBooleanRequestParameter ( $ request , 'exclude-ghosts' , false , false ) ; $ parentUuid = $ request -> get ( 'parentId' ) ; $ depth = $ request -> get ( 'depth' , 1 ) ; $ depth = intval ( $ depth ) ; $ flat = $ request -> get ( 'flat' , 'true' ) ; $ flat = ( 'true' === $ flat ) ; $ result = $ this -> getRepository ( ) -> getNodes ( $ parentUuid , $ webspace , $ language , $ depth , $ flat , false , $ excludeGhosts ) ; return $ this -> handleView ( $ this -> view ( $ result ) ) ; }
Returns complete nodes .
11,644
public function putAction ( Request $ request , $ id ) { $ language = $ this -> getLanguage ( $ request ) ; $ action = $ request -> get ( 'action' ) ; $ this -> checkActionParameterSecurity ( $ action , $ language , $ id ) ; $ document = $ this -> getDocumentManager ( ) -> find ( $ id , $ language , [ 'load_ghost_content' => false , 'load_shadow_content' => false , ] ) ; $ formType = $ this -> getMetadataFactory ( ) -> getMetadataForClass ( get_class ( $ document ) ) -> getFormType ( ) ; $ this -> get ( 'sulu_hash.request_hash_checker' ) -> checkHash ( $ request , $ document , $ document -> getUuid ( ) ) ; $ this -> persistDocument ( $ request , $ formType , $ document , $ language ) ; $ this -> handleActionParameter ( $ action , $ document , $ language ) ; $ this -> getDocumentManager ( ) -> flush ( ) ; $ context = new Context ( ) ; $ context -> setGroups ( [ 'defaultPage' ] ) ; return $ this -> handleView ( $ this -> view ( $ document ) -> setContext ( $ context ) ) ; }
saves node with given id and data .
11,645
public function postAction ( Request $ request ) { $ type = 'page' ; $ language = $ this -> getLanguage ( $ request ) ; $ action = $ request -> get ( 'action' ) ; $ this -> checkActionParameterSecurity ( $ action , $ language ) ; $ document = $ this -> getDocumentManager ( ) -> create ( $ type ) ; $ formType = $ this -> getMetadataFactory ( ) -> getMetadataForAlias ( $ type ) -> getFormType ( ) ; $ this -> persistDocument ( $ request , $ formType , $ document , $ language ) ; $ this -> handleActionParameter ( $ action , $ document , $ language ) ; $ this -> getDocumentManager ( ) -> flush ( ) ; $ context = new Context ( ) ; $ context -> setGroups ( [ 'defaultPage' ] ) ; return $ this -> handleView ( $ this -> view ( $ document ) -> setContext ( $ context ) ) ; }
Updates a content item and returns result as JSON String .
11,646
public function deleteAction ( Request $ request , $ id ) { $ language = $ this -> getLanguage ( $ request ) ; $ webspace = $ this -> getWebspace ( $ request ) ; $ force = $ this -> getBooleanRequestParameter ( $ request , 'force' , false , false ) ; if ( ! $ force ) { $ references = array_filter ( $ this -> getRepository ( ) -> getReferences ( $ id ) , function ( PropertyInterface $ reference ) { return $ reference -> getParent ( ) -> isNodeType ( 'sulu:page' ) ; } ) ; if ( count ( $ references ) > 0 ) { $ data = [ 'structures' => [ ] , 'other' => [ ] , ] ; foreach ( $ references as $ reference ) { $ content = $ this -> get ( 'sulu.content.mapper' ) -> load ( $ reference -> getParent ( ) -> getIdentifier ( ) , $ webspace , $ language , true ) ; $ data [ 'structures' ] [ ] = $ content -> toArray ( ) ; } return $ this -> handleView ( $ this -> view ( $ data , 409 ) ) ; } } $ view = $ this -> responseDelete ( $ id , function ( $ id ) use ( $ webspace ) { try { $ this -> getRepository ( ) -> deleteNode ( $ id , $ webspace ) ; } catch ( DocumentNotFoundException $ ex ) { throw new EntityNotFoundException ( 'Content' , $ id ) ; } } ) ; return $ this -> handleView ( $ view ) ; }
deletes node with given id .
11,647
private function checkActionParameterSecurity ( $ actionParameter , $ locale , $ id = null ) { $ permission = null ; switch ( $ actionParameter ) { case 'publish' : $ permission = 'live' ; break ; } if ( ! $ permission ) { return ; } $ this -> get ( 'sulu_security.security_checker' ) -> checkPermission ( new SecurityCondition ( $ this -> getSecurityContext ( ) , $ locale , $ this -> getSecuredClass ( ) , $ id ) , $ permission ) ; }
Checks if the user has the required permissions for the given action with the given locale . The additional id parameter will also include checks for the document identified by it .
11,648
private function handleActionParameter ( $ actionParameter , $ document , $ locale ) { switch ( $ actionParameter ) { case 'publish' : $ this -> getDocumentManager ( ) -> publish ( $ document , $ locale ) ; break ; } }
Delegates actions by given actionParameter which can be retrieved from the request .
11,649
public function addCondition ( \ Sulu \ Bundle \ ResourceBundle \ Entity \ Condition $ conditions ) { $ this -> conditions [ ] = $ conditions ; return $ this ; }
Add conditions .
11,650
public function removeCondition ( \ Sulu \ Bundle \ ResourceBundle \ Entity \ Condition $ conditions ) { $ this -> conditions -> removeElement ( $ conditions ) ; }
Remove conditions .
11,651
public function getIds ( ) { $ idsString = $ this -> getRequest ( ) -> get ( 'ids' ) ; return ( null !== $ idsString ) ? array_filter ( explode ( ',' , $ idsString ) ) : null ; }
Returns an array of ids to which the response should be restricted . If null is returned entities in the response should not be restricted by their id .
11,652
public function getExcludedIds ( ) { $ excludedIdsString = $ this -> getRequest ( ) -> get ( 'excludedIds' ) ; return ( null !== $ excludedIdsString ) ? array_filter ( explode ( ',' , $ excludedIdsString ) ) : [ ] ; }
Returns an array of ids which should be excluded from the response .
11,653
public function getLimit ( ) { $ default = 10 ; if ( 'csv' === $ this -> getRequest ( ) -> getRequestFormat ( ) ) { $ default = null ; } $ ids = $ this -> getIds ( ) ; if ( null != $ ids ) { $ default = count ( $ ids ) ; } return $ this -> getRequest ( ) -> get ( 'limit' , $ default ) ; }
Returns the maximum number of elements in a single response .
11,654
public function getFields ( ) { $ fields = $ this -> getRequest ( ) -> get ( 'fields' ) ; return ( null != $ fields ) ? explode ( ',' , $ fields ) : null ; }
Returns an array with all the fields which should be contained in the response . If null is returned every field should be contained .
11,655
protected function getLinkItem ( Content $ content , $ locale , $ scheme ) { $ published = ! empty ( $ content -> getPropertyWithDefault ( 'published' ) ) ; $ url = $ this -> webspaceManager -> findUrlByResourceLocator ( $ content -> getUrl ( ) , $ this -> environment , $ locale , $ content -> getWebspaceKey ( ) , null , $ scheme ) ; return new LinkItem ( $ content -> getId ( ) , $ content -> getPropertyWithDefault ( 'title' ) , $ url , $ published ) ; }
Returns new link item .
11,656
public function getFileVersion ( $ version ) { foreach ( $ this -> fileVersions as $ fileVersion ) { if ( $ fileVersion -> getVersion ( ) === $ version ) { return $ fileVersion ; } } return null ; }
Get file version .
11,657
public function setVersionMixin ( AbstractMappingEvent $ event ) { if ( ! $ this -> support ( $ event -> getDocument ( ) ) ) { return ; } $ event -> getNode ( ) -> addMixin ( 'mix:versionable' ) ; }
Sets the versionable mixin on the node if it is a versionable document .
11,658
public function setVersionsOnDocument ( HydrateEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ this -> support ( $ document ) ) { return ; } $ node = $ event -> getNode ( ) ; $ versions = [ ] ; $ versionProperty = $ node -> getPropertyValueWithDefault ( static :: VERSION_PROPERTY , [ ] ) ; foreach ( $ versionProperty as $ version ) { $ versionInformation = json_decode ( $ version ) ; $ versions [ ] = new Version ( $ versionInformation -> version , $ versionInformation -> locale , $ versionInformation -> author , new \ DateTime ( $ versionInformation -> authored ) ) ; } $ document -> setVersions ( $ versions ) ; }
Sets the version information set on the node to the document .
11,659
public function rememberCheckoutUuids ( PersistEvent $ event ) { if ( ! $ this -> support ( $ event -> getDocument ( ) ) ) { return ; } $ this -> checkoutUuids [ ] = $ event -> getNode ( ) -> getIdentifier ( ) ; }
Remember which uuids need to be checked out after everything has been saved .
11,660
public function rememberCreateVersion ( PublishEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ this -> support ( $ document ) ) { return ; } $ this -> checkpointUuids [ ] = [ 'uuid' => $ event -> getNode ( ) -> getIdentifier ( ) , 'locale' => $ document -> getLocale ( ) , 'author' => $ event -> getOption ( 'user' ) , ] ; }
Remember for which uuids a new version has to be created .
11,661
public function applyVersionOperations ( ) { foreach ( $ this -> checkoutUuids as $ uuid ) { $ node = $ this -> defaultSession -> getNodeByIdentifier ( $ uuid ) ; $ path = $ node -> getPath ( ) ; if ( ! $ this -> versionManager -> isCheckedOut ( $ path ) ) { $ this -> versionManager -> checkout ( $ path ) ; } } $ this -> checkoutUuids = [ ] ; $ nodes = [ ] ; $ nodeVersions = [ ] ; foreach ( $ this -> checkpointUuids as $ versionInformation ) { $ node = $ this -> defaultSession -> getNodeByIdentifier ( $ versionInformation [ 'uuid' ] ) ; $ path = $ node -> getPath ( ) ; $ version = $ this -> versionManager -> checkpoint ( $ path ) ; if ( ! array_key_exists ( $ path , $ nodes ) ) { $ nodes [ $ path ] = $ this -> defaultSession -> getNode ( $ path ) ; } $ versions = $ nodes [ $ path ] -> getPropertyValueWithDefault ( static :: VERSION_PROPERTY , [ ] ) ; if ( ! array_key_exists ( $ path , $ nodeVersions ) ) { $ nodeVersions [ $ path ] = $ versions ; } $ nodeVersions [ $ path ] [ ] = json_encode ( [ 'locale' => $ versionInformation [ 'locale' ] , 'version' => $ version -> getName ( ) , 'author' => $ versionInformation [ 'author' ] , 'authored' => date ( 'c' ) , ] ) ; } foreach ( $ nodes as $ uuid => $ node ) { $ node -> setProperty ( static :: VERSION_PROPERTY , $ nodeVersions [ $ uuid ] ) ; } $ this -> defaultSession -> save ( ) ; $ this -> checkpointUuids = [ ] ; }
Apply all the operations which have been remembered after the flush .
11,662
public function restoreProperties ( RestoreEvent $ event ) { if ( ! $ this -> support ( $ event -> getDocument ( ) ) ) { $ event -> stopPropagation ( ) ; return ; } $ contentPropertyPrefix = $ this -> propertyEncoder -> localizedContentName ( '' , $ event -> getLocale ( ) ) ; $ systemPropertyPrefix = $ this -> propertyEncoder -> localizedSystemName ( '' , $ event -> getLocale ( ) ) ; $ node = $ event -> getNode ( ) ; try { $ version = $ this -> versionManager -> getVersionHistory ( $ node -> getPath ( ) ) -> getVersion ( $ event -> getVersion ( ) ) ; $ frozenNode = $ version -> getFrozenNode ( ) ; $ this -> restoreNode ( $ node , $ frozenNode , $ contentPropertyPrefix , $ systemPropertyPrefix ) ; } catch ( VersionException $ exception ) { throw new VersionNotFoundException ( $ event -> getDocument ( ) , $ event -> getVersion ( ) ) ; } }
Restore the properties of the old version .
11,663
private function restoreNode ( NodeInterface $ node , NodeInterface $ frozenNode , $ contentPropertyPrefix , $ systemPropertyPrefix ) { foreach ( $ node -> getProperties ( ) as $ property ) { if ( $ this -> isRestoreProperty ( $ property -> getName ( ) , $ contentPropertyPrefix , $ systemPropertyPrefix ) ) { $ property -> remove ( ) ; } } foreach ( $ frozenNode -> getPropertiesValues ( ) as $ name => $ value ) { if ( $ this -> isRestoreProperty ( $ name , $ contentPropertyPrefix , $ systemPropertyPrefix ) ) { $ node -> setProperty ( $ name , $ value ) ; } } foreach ( $ frozenNode -> getNodes ( ) as $ childNode ) { if ( ! $ node -> hasNode ( $ childNode -> getName ( ) ) ) { $ newNode = $ node -> addNode ( $ childNode -> getName ( ) ) ; $ newNode -> setMixins ( $ childNode -> getPropertyValueWithDefault ( 'jcr:frozenMixinTypes' , [ ] ) ) ; } $ this -> restoreNode ( $ node -> getNode ( $ childNode -> getName ( ) ) , $ childNode , $ contentPropertyPrefix , $ systemPropertyPrefix ) ; } foreach ( $ node -> getNodes ( ) as $ childNode ) { if ( OnParentVersionAction :: COPY !== $ childNode -> getDefinition ( ) -> getOnParentVersion ( ) || $ frozenNode -> hasNode ( $ childNode -> getName ( ) ) ) { continue ; } $ childNode -> remove ( ) ; } }
Restore given node with properties given from frozen - node . Will be called recursive .
11,664
public function addSetting ( RoleSettingInterface $ setting ) { $ this -> settings -> set ( $ setting -> getKey ( ) , $ setting ) ; return $ this ; }
Add setting .
11,665
private function createWebspaceNode ( $ webspaceKey , $ languageCode , $ depth = 1 , $ excludeGhosts = false ) { $ webspace = $ this -> webspaceManager -> getWebspaceCollection ( ) -> getWebspace ( $ webspaceKey ) ; if ( $ depth > 0 ) { $ nodes = $ this -> getMapper ( ) -> loadByParent ( null , $ webspaceKey , $ languageCode , $ depth , false , false , $ excludeGhosts ) ; $ embedded = $ this -> prepareNodesTree ( $ nodes , $ webspaceKey , $ languageCode , true , $ excludeGhosts , $ depth ) ; } else { $ embedded = [ ] ; } return [ 'id' => $ this -> sessionManager -> getContentNode ( $ webspace -> getKey ( ) ) -> getIdentifier ( ) , 'path' => '/' , 'title' => $ webspace -> getName ( ) , 'hasSub' => true , 'publishedState' => true , '_embedded' => $ embedded , '_links' => [ 'children' => [ 'href' => $ this -> apiBasePath . '?depth=' . $ depth . '&webspace=' . $ webspaceKey . '&language=' . $ languageCode . ( true === $ excludeGhosts ? '&exclude-ghosts=true' : '' ) , ] , ] , ] ; }
Creates a webspace node .
11,666
private function getParentNode ( $ parent , $ webspaceKey , $ languageCode ) { if ( null != $ parent ) { return $ this -> getMapper ( ) -> load ( $ parent , $ webspaceKey , $ languageCode ) ; } else { return $ this -> getMapper ( ) -> loadStartPage ( $ webspaceKey , $ languageCode ) ; } }
if parent is null return home page else the page with given uuid .
11,667
private function loadNodeAndAncestors ( $ uuid , $ webspaceKey , $ locale , $ excludeGhosts , $ excludeShadows , $ complete ) { $ descendants = $ this -> getMapper ( ) -> loadNodeAndAncestors ( $ uuid , $ locale , $ webspaceKey , $ excludeGhosts , $ excludeShadows ) ; $ descendants = array_reverse ( $ descendants ) ; $ childTiers = [ ] ; foreach ( $ descendants as $ descendant ) { foreach ( $ descendant -> getChildren ( ) as $ child ) { $ type = $ child -> getType ( ) ; if ( $ excludeShadows && null !== $ type && 'shadow' === $ type -> getName ( ) ) { continue ; } if ( $ excludeGhosts && null !== $ type && 'ghost' === $ type -> getName ( ) ) { continue ; } if ( ! isset ( $ childTiers [ $ descendant -> getUuid ( ) ] ) ) { $ childTiers [ $ descendant -> getUuid ( ) ] = [ ] ; } $ childTiers [ $ descendant -> getUuid ( ) ] [ ] = $ this -> prepareNode ( $ child , $ webspaceKey , $ locale , 1 , $ complete , $ excludeGhosts ) ; } } $ result = array_shift ( $ childTiers ) ; $ this -> iterateTiers ( $ childTiers , $ result ) ; return $ result ; }
Load the node and its ancestors and convert them into a HATEOAS representation .
11,668
private function iterateTiers ( $ tiers , & $ result ) { reset ( $ tiers ) ; $ uuid = key ( $ tiers ) ; $ tier = array_shift ( $ tiers ) ; $ found = false ; if ( is_array ( $ result ) ) { foreach ( $ result as & $ node ) { if ( $ node [ 'id' ] === $ uuid ) { $ node [ '_embedded' ] [ 'nodes' ] = $ tier ; $ found = true ; break ; } } } if ( ! $ tiers ) { return ; } if ( ! $ found ) { throw new \ RuntimeException ( sprintf ( 'Could not find target node in with UUID "%s" in tier. This should not happen.' , $ uuid ) ) ; } $ this -> iterateTiers ( $ tiers , $ node [ '_embedded' ] [ 'nodes' ] ) ; }
Iterate over the ancestor tiers and build up the result .
11,669
public static function getDebugTitle ( $ document ) { $ title = spl_object_hash ( $ document ) ; if ( $ document instanceof PathBehavior && $ document -> getPath ( ) ) { $ title .= ' (' . $ document -> getPath ( ) . ')' ; } elseif ( $ document instanceof TitleBehavior && $ document -> getTitle ( ) ) { $ title .= ' (' . $ document -> getTitle ( ) . ')' ; } return $ title ; }
Return a debug title for the document for use in exception messages .
11,670
public function onAuthenticationSuccess ( Request $ request , TokenInterface $ token ) { if ( $ this -> session -> get ( '_security.admin.target_path' ) && false !== strpos ( $ this -> session -> get ( '_security.admin.target_path' ) , '#' ) ) { $ url = $ this -> session -> get ( '_security.admin.target_path' ) ; } else { $ url = $ this -> router -> generate ( 'sulu_admin' ) ; } if ( $ request -> isXmlHttpRequest ( ) ) { $ array = [ 'url' => $ url ] ; $ response = new JsonResponse ( $ array , 200 ) ; } else { $ response = new RedirectResponse ( $ url ) ; } return $ response ; }
Handler for AuthenticationSuccess . Returns a JsonResponse if request is an AJAX - request . Returns a RedirectResponse otherwise .
11,671
public function onAuthenticationFailure ( Request $ request , AuthenticationException $ exception ) { if ( $ request -> isXmlHttpRequest ( ) ) { $ array = [ 'message' => $ exception -> getMessage ( ) ] ; $ response = new JsonResponse ( $ array , 401 ) ; } else { $ this -> session -> set ( Security :: AUTHENTICATION_ERROR , $ exception ) ; $ response = new RedirectResponse ( $ this -> router -> generate ( 'sulu_admin.login' ) ) ; } return $ response ; }
Handler for AuthenticationFailure . Returns a JsonResponse if request is an AJAX - request . Returns a Redirect - response otherwise .
11,672
public function toArray ( ) { $ this -> init ( ) ; $ values = [ ] ; foreach ( array_keys ( $ this -> structureMetadata -> getProperties ( ) ) as $ childName ) { $ values [ $ childName ] = $ this -> normalize ( $ this -> getProperty ( $ childName ) -> getValue ( ) ) ; } return $ values ; }
Return an array copy of the property data .
11,673
public function setWorkflowStageOnDocument ( HydrateEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ this -> supports ( $ event ) ) { return ; } $ node = $ event -> getNode ( ) ; $ locale = $ event -> getLocale ( ) ; $ document -> setWorkflowStage ( $ node -> getPropertyValueWithDefault ( $ this -> propertyEncoder -> localizedSystemName ( self :: WORKFLOW_STAGE_FIELD , $ locale ) , WorkflowStage :: TEST ) ) ; $ event -> getAccessor ( ) -> set ( self :: PUBLISHED_FIELD , $ node -> getPropertyValueWithDefault ( $ this -> propertyEncoder -> localizedSystemName ( self :: PUBLISHED_FIELD , $ locale ) , null ) ) ; }
Sets the workflow properties from the node on the document .
11,674
public function setWorkflowStageToPublished ( PublishEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ this -> supports ( $ event ) ) { return ; } $ this -> setWorkflowStage ( $ document , $ event -> getAccessor ( ) , WorkflowStage :: PUBLISHED , $ event -> getLocale ( ) , true ) ; }
Sets the workflow stage for the passed document to published .
11,675
private function setWorkflowStage ( WorkflowStageBehavior $ document , DocumentAccessor $ accessor , $ workflowStage , $ locale , $ live ) { $ path = $ this -> documentInspector -> getPath ( $ document ) ; $ document -> setWorkflowStage ( $ workflowStage ) ; $ publishDate = $ document -> getPublished ( ) ; if ( ! $ publishDate && WorkflowStage :: PUBLISHED === $ workflowStage ) { $ publishDate = new \ DateTime ( ) ; $ accessor -> set ( self :: PUBLISHED_FIELD , $ publishDate ) ; } $ defaultNode = $ this -> defaultSession -> getNode ( $ path ) ; $ this -> setWorkflowStageOnNode ( $ defaultNode , $ locale , $ workflowStage , $ publishDate ) ; if ( $ live ) { $ liveNode = $ this -> liveSession -> getNode ( $ path ) ; $ this -> setWorkflowStageOnNode ( $ liveNode , $ locale , $ workflowStage , $ publishDate ) ; } }
Sets the workflow properties on the given document .
11,676
private function setWorkflowStageOnNode ( NodeInterface $ node , $ locale , $ workflowStage , \ DateTime $ publishDate = null ) { $ node -> setProperty ( $ this -> propertyEncoder -> localizedSystemName ( self :: WORKFLOW_STAGE_FIELD , $ locale ) , $ workflowStage ) ; if ( $ publishDate ) { $ node -> setProperty ( $ this -> propertyEncoder -> localizedSystemName ( self :: PUBLISHED_FIELD , $ locale ) , $ publishDate ) ; } }
Sets the workflow stage properties on the given node .
11,677
private function cleanup ( OutputInterface $ output , NodeInterface $ node , $ rootPath , $ dryRun ) { foreach ( $ node -> getNodes ( ) as $ childNode ) { $ this -> cleanup ( $ output , $ childNode , $ rootPath , $ dryRun ) ; } $ path = ltrim ( str_replace ( $ rootPath , '' , $ node -> getPath ( ) ) , '/' ) ; if ( ! $ node -> getPropertyValueWithDefault ( 'sulu:history' , false ) ) { $ output -> writeln ( '<info>Processing aborted: </info>/' . $ path . ' <comment>(no history url)</comment>' ) ; return ; } if ( false === $ dryRun ) { $ node -> remove ( ) ; } $ output -> writeln ( '<info>Processing: </info>/' . $ path ) ; }
Cleanup specific node and his children .
11,678
private function getUserObjectPermission ( SecurityCondition $ securityCondition , UserInterface $ user ) { $ permissions = $ this -> getPermissions ( $ securityCondition -> getObjectType ( ) , $ securityCondition -> getObjectId ( ) ) ; return $ this -> getUserObjectPermissionByArray ( $ permissions , $ user ) ; }
Returns the permissions for the given object for the given user .
11,679
private function getUserObjectPermissionByArray ( $ permissions , UserInterface $ user ) { if ( empty ( $ permissions ) ) { return [ ] ; } $ userPermission = [ ] ; $ roles = $ user -> getRoleObjects ( ) ; foreach ( $ roles as $ role ) { $ roleId = $ role -> getId ( ) ; if ( ! isset ( $ permissions [ $ roleId ] ) ) { continue ; } $ userPermission = $ this -> cumulatePermissions ( $ userPermission , $ permissions [ $ roleId ] ) ; } return $ userPermission ; }
Returns the permissions for the given permission array and the given user .
11,680
private function getUserSecurityContextPermissions ( $ locale , $ securityContext , UserInterface $ user , $ checkPermissionType ) { $ userPermissions = [ ] ; foreach ( $ user -> getUserRoles ( ) as $ userRole ) { $ userPermissions = $ this -> cumulatePermissions ( $ userPermissions , $ this -> getUserRoleSecurityContextPermission ( $ locale , $ securityContext , $ userRole , $ checkPermissionType ) ) ; } return $ userPermissions ; }
Returns the permissions for the given security context for the given user .
11,681
private function getUserRoleSecurityContextPermission ( $ locale , $ securityContext , UserRole $ userRole , $ checkPermissionType ) { $ userPermission = $ this -> maskConverter -> convertPermissionsToArray ( 0 ) ; foreach ( $ userRole -> getRole ( ) -> getPermissions ( ) as $ permission ) { $ hasContext = $ permission -> getContext ( ) == $ securityContext ; if ( ! $ hasContext ) { continue ; } $ hasLocale = null == $ locale || in_array ( $ locale , $ userRole -> getLocales ( ) ) ; if ( ! $ hasLocale ) { continue ; } if ( $ checkPermissionType ) { $ userPermission = $ this -> maskConverter -> convertPermissionsToArray ( $ permission -> getPermissions ( ) ) ; } else { array_walk ( $ userPermission , function ( & $ permission ) { $ permission = true ; } ) ; } } return $ userPermission ; }
Returns the permissions for the given security context for the given user role .
11,682
private function cumulatePermissions ( array $ userPermission , array $ permissions ) { return $ this -> mapPermissions ( $ userPermission , $ permissions , function ( $ permission1 , $ permission2 ) { return $ permission1 || $ permission2 ; } ) ; }
Merges all the true values for the given permission arrays .
11,683
private function restrictPermissions ( array $ userPermission , array $ permissions ) { return $ this -> mapPermissions ( $ userPermission , $ permissions , function ( $ permission1 , $ permission2 ) { return $ permission1 && $ permission2 ; } ) ; }
Merges all the values for the given permission arrays . Only returns true if all values are true .
11,684
private function getAccessControlProvider ( $ type ) { foreach ( $ this -> accessControlProviders as $ accessControlProvider ) { if ( $ accessControlProvider -> supports ( $ type ) ) { return $ accessControlProvider ; } } }
Returns the AccessControlProvider which supports the given type .
11,685
private function findAccountsByIds ( $ ids ) { if ( 0 === count ( $ ids ) ) { return [ ] ; } $ queryBuilder = $ this -> entityManager -> createQueryBuilder ( ) -> select ( 'CONCAT(\'a\', a.id) AS id, a.name AS name' ) -> from ( $ this -> accountEntityClass , 'a' ) -> where ( 'a.id IN (:ids)' ) ; $ query = $ queryBuilder -> getQuery ( ) ; $ query -> setParameter ( 'ids' , $ ids ) ; return $ query -> getArrayResult ( ) ; }
Returns array of accounts by ids .
11,686
private function findContactsByIds ( $ ids ) { if ( 0 === count ( $ ids ) ) { return [ ] ; } $ queryBuilder = $ this -> entityManager -> createQueryBuilder ( ) -> select ( 'CONCAT(\'c\', c.id) AS id, CONCAT(CONCAT(c.firstName, \' \'), c.lastName) AS name' ) -> from ( $ this -> contactEntityClass , 'c' ) -> where ( 'c.id IN (:ids)' ) ; $ query = $ queryBuilder -> getQuery ( ) ; $ query -> setParameter ( 'ids' , $ ids ) ; return $ query -> getArrayResult ( ) ; }
Returns array of contacts by ids .
11,687
public function cgetAction ( $ id , Request $ request ) { $ formatOptions = $ this -> getFormatOptionsManager ( ) -> getAll ( $ id ) ; return $ this -> handleView ( $ this -> view ( count ( $ formatOptions ) > 0 ? $ formatOptions : new \ stdClass ( ) ) ) ; }
Returns all format resources .
11,688
public function putAction ( $ id , $ key , Request $ request ) { $ options = $ request -> request -> all ( ) ; if ( empty ( $ options ) ) { $ this -> getFormatOptionsManager ( ) -> delete ( $ id , $ key ) ; } else { $ this -> getFormatOptionsManager ( ) -> save ( $ id , $ key , $ options ) ; } $ this -> get ( 'doctrine.orm.entity_manager' ) -> flush ( ) ; $ formatOptions = $ this -> getFormatOptionsManager ( ) -> get ( $ id , $ key ) ; return $ this -> handleView ( $ this -> view ( $ formatOptions ) ) ; }
Edits a format resource .
11,689
private function dumpProviderSitemap ( $ alias , PortalInformation $ portalInformation , $ scheme ) { $ maxPage = $ this -> sitemapProviderPool -> getProvider ( $ alias ) -> getMaxPage ( ) ; for ( $ page = 1 ; $ page <= $ maxPage ; ++ $ page ) { $ sitemap = $ this -> sitemapRenderer -> renderSitemap ( $ alias , $ page , $ portalInformation -> getLocale ( ) , $ portalInformation -> getPortal ( ) , $ portalInformation -> getHost ( ) , $ scheme ) ; $ this -> dumpFile ( $ this -> getDumpPath ( $ scheme , $ portalInformation -> getWebspaceKey ( ) , $ portalInformation -> getLocale ( ) , $ portalInformation -> getHost ( ) , $ alias , $ page ) , $ sitemap ) ; } }
Render sitemap for provider .
11,690
private function removeRoute ( StructureBehavior $ document ) { foreach ( $ this -> documentInspector -> getReferrers ( $ document ) as $ referrer ) { if ( $ referrer instanceof RouteBehavior ) { $ this -> documentManager -> remove ( $ referrer ) ; } } }
Removes related route of given document .
11,691
public function getPropertyWithDefault ( $ name , $ default = null ) { if ( ! array_key_exists ( $ name , $ this -> data ) ) { return $ default ; } return $ this -> data [ $ name ] ; }
Returns value for given property or given default .
11,692
public function compareEntitiesWithData ( $ entities , array $ requestEntities , callable $ compare , callable $ add = null , callable $ update = null , callable $ delete = null ) { $ matchFunction = function ( $ entity , $ requestEntities , & $ matchedEntry , & $ matchedKey ) use ( $ compare ) { $ this -> findMatchByCallback ( $ entity , $ requestEntities , $ compare , $ matchedEntry , $ matchedKey ) ; } ; return $ this -> compareData ( $ entities , $ requestEntities , $ matchFunction , $ add , $ update , $ delete ) ; }
Compares entities with data array and calls the given callbacks .
11,693
public function compareData ( $ entities , array $ requestEntities , callable $ compare = null , callable $ add = null , callable $ update = null , callable $ delete = null ) { $ success = true ; if ( ! empty ( $ entities ) ) { foreach ( $ entities as $ entity ) { $ matchedEntry = null ; $ matchedKey = null ; $ compare ( $ entity , $ requestEntities , $ matchedEntry , $ matchedKey ) ; if ( null == $ matchedEntry && null != $ delete ) { $ delete ( $ entity ) ; } elseif ( null != $ update ) { $ success = $ update ( $ entity , $ matchedEntry ) ; if ( ! $ success ) { break ; } } if ( null !== $ matchedKey ) { unset ( $ requestEntities [ $ matchedKey ] ) ; } } } if ( ! empty ( $ requestEntities ) && null != $ add ) { foreach ( $ requestEntities as $ entity ) { if ( ! $ success ) { break ; } $ success = $ add ( $ entity ) ; } } return $ success ; }
function compares entities with data of array and makes callback .
11,694
public function removeFaxe ( \ Sulu \ Bundle \ ContactBundle \ Entity \ Fax $ faxes ) { $ this -> faxes -> removeElement ( $ faxes ) ; }
Remove faxes .
11,695
public function removeAddresse ( \ Sulu \ Bundle \ ContactBundle \ Entity \ Address $ addresses ) { $ this -> addresses -> removeElement ( $ addresses ) ; }
Remove addresses .
11,696
public function setTitleOnDocument ( AbstractMappingEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ this -> supports ( $ document ) ) { return ; } if ( $ document instanceof LocalizedTitleBehavior ) { if ( ! $ event -> getLocale ( ) ) { return ; } $ document -> setTitle ( $ event -> getNode ( ) -> getPropertyValueWithDefault ( $ this -> propertyEncoder -> localizedContentName ( static :: PROPERTY_NAME , $ event -> getLocale ( ) ) , '' ) ) ; } else { $ document -> setTitle ( $ event -> getNode ( ) -> getPropertyValueWithDefault ( $ this -> propertyEncoder -> contentName ( static :: PROPERTY_NAME ) , '' ) ) ; } }
Sets the title on the document from the node .
11,697
public function setTitleOnNode ( AbstractMappingEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ this -> supports ( $ document ) ) { return ; } if ( $ document instanceof LocalizedTitleBehavior ) { if ( ! $ event -> getLocale ( ) ) { return ; } $ event -> getNode ( ) -> setProperty ( $ this -> propertyEncoder -> localizedContentName ( static :: PROPERTY_NAME , $ event -> getLocale ( ) ) , $ document -> getTitle ( ) ) ; } else { $ event -> getNode ( ) -> setProperty ( $ this -> propertyEncoder -> contentName ( static :: PROPERTY_NAME ) , $ document -> getTitle ( ) ) ; } }
Sets the title on the node from the value in the document .
11,698
public function getRepository ( $ entityName ) { return new ListRepository ( $ this -> em , $ this -> em -> getClassMetadata ( $ entityName ) , $ this ) ; }
Create a ListRepository for given EntityName .
11,699
public function find ( $ entityName , $ where = [ ] , $ joinConditions = [ ] ) { return $ this -> getRepository ( $ entityName ) -> find ( $ where , 'u' , false , $ joinConditions ) ; }
Create a ListRepository for given EntityName and find Entities for list .