idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
11,100
public function delete ( $ id ) { $ tag = $ this -> tagRepository -> findTagById ( $ id ) ; if ( ! $ tag ) { throw new TagNotFoundException ( $ id ) ; } $ this -> em -> remove ( $ tag ) ; $ this -> em -> flush ( ) ; $ event = new TagDeleteEvent ( $ tag ) ; $ this -> eventDispatcher -> dispatch ( TagEvents :: TAG_DELETE...
Deletes the given Tag .
11,101
public function merge ( $ srcTagIds , $ destTagId ) { $ srcTags = [ ] ; $ destTag = $ this -> tagRepository -> findTagById ( $ destTagId ) ; if ( ! $ destTag ) { throw new TagNotFoundException ( $ destTagId ) ; } foreach ( $ srcTagIds as $ srcTagId ) { $ srcTag = $ this -> tagRepository -> findTagById ( $ srcTagId ) ; ...
Merges the source tag into the destination tag . The source tag will be deleted .
11,102
public function resolveTagIds ( $ tagIds ) { $ resolvedTags = [ ] ; foreach ( $ tagIds as $ tagId ) { $ tag = $ this -> findById ( $ tagId ) ; if ( null !== $ tag ) { $ resolvedTags [ ] = $ tag -> getName ( ) ; } } return $ resolvedTags ; }
Resolves tag ids to names .
11,103
public function resolveTagNames ( $ tagNames ) { $ resolvedTags = [ ] ; foreach ( $ tagNames as $ tagName ) { $ tag = $ this -> findByName ( $ tagName ) ; if ( null !== $ tag ) { $ resolvedTags [ ] = $ tag -> getId ( ) ; } } return $ resolvedTags ; }
Resolves tag names to ids .
11,104
public function createSelfLink ( ) { if ( is_null ( $ this -> getApiPath ( ) ) ) { $ class = explode ( '\\' , get_class ( $ this ) ) ; $ plural = Inflector :: pluralize ( strtolower ( end ( $ class ) ) ) ; $ this -> apiPath = $ this -> apiBasePath . '/' . $ plural ; } $ idPath = '' ; if ( $ this -> getId ( ) ) { $ idPa...
creates the _links array including the self path .
11,105
public function getProperty ( $ name ) { foreach ( $ this -> getChildProperties ( ) as $ property ) { if ( $ property -> getName ( ) === $ name ) { return $ property ; } } return ; }
returns child property with given name .
11,106
public function getChild ( $ name ) { foreach ( $ this -> childProperties as $ child ) { if ( $ child -> getName ( ) === $ name ) { return $ child ; } } throw new NoSuchPropertyException ( ) ; }
returns property with given name .
11,107
public function evaluate ( array $ options ) { $ request = $ this -> requestStack -> getCurrentRequest ( ) ; $ referrer = $ request -> headers -> get ( 'referer' ) ; if ( $ this -> referrerHeader && $ request -> headers -> has ( $ this -> referrerHeader ) ) { $ referrer = $ request -> headers -> get ( $ this -> referre...
Returns a string representation of the evaluation of the rule for the current context .
11,108
private function loadFormatsFromFile ( $ path , array & $ formats ) { $ folder = dirname ( $ path ) ; $ file = basename ( $ path ) ; $ locator = new FileLocator ( $ folder ) ; $ xmlLoader10 = new XmlFormatLoader10 ( $ locator ) ; $ xmlLoader11 = new XmlFormatLoader11 ( $ locator ) ; $ xmlLoader10 -> setGlobalOptions ( ...
Adds the image formats from the file at the given path to the given array .
11,109
public function cgetAction ( $ webspace , Request $ request ) { $ result = $ this -> get ( 'sulu_custom_urls.manager' ) -> findList ( $ webspace ) ; $ list = new RouteAwareRepresentation ( new CollectionRepresentation ( $ result , self :: $ relationName ) , 'cget_webspace_custom-urls' , array_merge ( $ request -> reque...
Returns a list of custom - urls .
11,110
public function getAction ( $ webspace , $ id , Request $ request ) { $ document = $ this -> get ( 'sulu_custom_urls.manager' ) -> find ( $ id ) ; if ( null !== $ document -> getTargetDocument ( ) ) { $ document -> getTargetDocument ( ) -> getTitle ( ) ; } $ view = $ this -> view ( $ document ) ; $ context = new Contex...
Returns a single custom - url identified by uuid .
11,111
public function postAction ( $ webspace , Request $ request ) { $ document = $ this -> get ( 'sulu_custom_urls.manager' ) -> create ( $ webspace , $ request -> request -> all ( ) , $ this -> getRequestParameter ( $ request , 'targetLocale' , true ) ) ; $ this -> get ( 'sulu_document_manager.document_manager' ) -> flush...
Create a new custom - url object .
11,112
public function putAction ( $ webspace , $ id , Request $ request ) { $ manager = $ this -> get ( 'sulu_custom_urls.manager' ) ; $ document = $ manager -> save ( $ id , $ request -> request -> all ( ) ) ; $ this -> get ( 'sulu_document_manager.document_manager' ) -> flush ( ) ; $ context = new Context ( ) ; $ context -...
Update an existing custom - url object identified by uuid .
11,113
public function deleteAction ( $ webspace , $ id ) { $ manager = $ this -> get ( 'sulu_custom_urls.manager' ) ; $ manager -> delete ( $ id ) ; $ this -> get ( 'sulu_document_manager.document_manager' ) -> flush ( ) ; return $ this -> handleView ( $ this -> view ( ) ) ; }
Delete a single custom - url identified by uuid .
11,114
public function cdeleteAction ( $ webspace , Request $ request ) { $ ids = array_filter ( explode ( ',' , $ request -> get ( 'ids' , '' ) ) ) ; $ manager = $ this -> get ( 'sulu_custom_urls.manager' ) ; foreach ( $ ids as $ ids ) { $ manager -> delete ( $ ids ) ; } $ this -> get ( 'sulu_document_manager.document_manage...
Deletes a list of custom - urls identified by a list of uuids .
11,115
public function getParent ( $ document ) { $ parentNode = $ this -> getNode ( $ document ) -> getParent ( ) ; if ( ! $ parentNode ) { return ; } return $ this -> proxyFactory -> createProxyForNode ( $ document , $ parentNode ) ; }
Return the parent document for the given document .
11,116
private function getLocalizedMeta ( ) { if ( $ this -> localizedMeta ) { return $ this -> localizedMeta ; } $ metas = $ this -> getFileVersion ( ) -> getMeta ( ) ; $ this -> localizedMeta = $ metas [ 0 ] ; foreach ( $ metas as $ key => $ meta ) { if ( $ meta -> getLocale ( ) == $ this -> locale ) { $ this -> localizedM...
Searches the meta for the file version in the media locale . Might also return a fallback .
11,117
public function addCategory ( CategoryEntity $ category ) { $ fileVersion = $ this -> getFileVersion ( ) ; $ fileVersion -> addCategory ( $ category ) ; return $ this ; }
Adds a category to the entity .
11,118
public function getCategories ( ) { $ apiCategories = [ ] ; $ fileVersion = $ this -> getFileVersion ( ) ; $ categories = $ fileVersion -> getCategories ( ) ; return array_map ( function ( CategoryEntity $ category ) { return $ category -> getId ( ) ; } , $ categories -> toArray ( ) ) ; }
Returns the categories of the media .
11,119
public function addTargetGroup ( TargetGroupInterface $ targetGroup ) { $ fileVersion = $ this -> getFileVersion ( ) ; $ fileVersion -> addTargetGroup ( $ targetGroup ) ; return $ this ; }
Adds a target group to the entity .
11,120
private function dumpWebspace ( Webspace $ webspace ) { foreach ( $ webspace -> getAllLocalizations ( ) as $ localization ) { $ this -> output -> writeln ( sprintf ( ' - %s (%s)' , $ webspace -> getKey ( ) , $ localization -> getLocale ( ) ) ) ; $ this -> dumpPortalInformations ( $ this -> webspaceManager -> findPortal...
Dump given webspace .
11,121
private function dumpPortalInformations ( array $ portalInformations ) { try { foreach ( $ portalInformations as $ portalInformation ) { $ this -> sitemapDumper -> dumpPortalInformation ( $ portalInformation , $ this -> scheme ) ; } } catch ( \ InvalidArgumentException $ exception ) { $ this -> clear ( ) ; throw $ exce...
Dump given portal - informations .
11,122
public function addAddress ( $ account , AddressEntity $ address , $ isMain = false ) { if ( ! $ account || ! $ address ) { throw new \ Exception ( 'Account and Address cannot be null' ) ; } $ accountAddress = new AccountAddressEntity ( ) ; $ accountAddress -> setAccount ( $ account ) ; $ accountAddress -> setAddress (...
Adds an address to the entity .
11,123
public function removeAddressRelation ( $ account , $ accountAddress ) { if ( ! $ account || ! $ accountAddress ) { throw new \ Exception ( 'Account and AccountAddress cannot be null' ) ; } $ address = $ accountAddress -> getAddress ( ) ; $ address = $ this -> em -> getRepository ( 'SuluContactBundle:Address' ) -> find...
Removes the address relation from a contact and also deletes the address if it has no more relations .
11,124
public function getById ( $ id , $ locale ) { $ account = $ this -> accountRepository -> findAccountById ( $ id ) ; if ( ! $ account ) { throw new EntityNotFoundException ( $ this -> accountRepository -> getClassName ( ) , $ id ) ; } return $ this -> getApiObject ( $ account , $ locale ) ; }
Gets account by id .
11,125
public function getByIds ( $ ids , $ locale ) { if ( ! is_array ( $ ids ) || 0 === count ( $ ids ) ) { return [ ] ; } $ accounts = $ this -> accountRepository -> findByIds ( $ ids ) ; return array_map ( function ( $ account ) use ( $ locale ) { return $ this -> getApiObject ( $ account , $ locale ) ; } , $ accounts ) ;...
Returns account entities by ids .
11,126
public function getByIdAndInclude ( $ id , $ locale , $ includes ) { $ account = $ this -> accountRepository -> findAccountById ( $ id , in_array ( 'contacts' , $ includes ) ) ; if ( ! $ account ) { throw new EntityNotFoundException ( $ this -> accountRepository -> getClassName ( ) , $ id ) ; } return $ this -> getApiO...
Gets account by id - can include relations .
11,127
public function findContactsByAccountId ( $ id , $ locale , $ onlyFetchMainAccounts = false ) { $ contactsEntities = $ this -> contactRepository -> findByAccountId ( $ id , null , false , $ onlyFetchMainAccounts ) ; if ( ! empty ( $ contactsEntities ) ) { $ contacts = [ ] ; foreach ( $ contactsEntities as $ contact ) {...
Returns contacts by account id .
11,128
public function setMedias ( Account $ account , $ medias ) { $ mediaIds = array_map ( function ( $ media ) { return $ media [ 'id' ] ; } , $ medias ) ; $ foundMedias = $ this -> mediaRepository -> findById ( $ mediaIds ) ; $ foundMediaIds = array_map ( function ( $ mediaEntity ) { return $ mediaEntity -> getId ( ) ; } ...
Sets the medias of the given account to the given medias . Currently associated medias are replaced .
11,129
public function findAll ( $ locale , $ filter = null ) { if ( $ filter ) { $ accountEntities = $ this -> accountRepository -> findByFilter ( $ filter ) ; } else { $ accountEntities = $ this -> accountRepository -> findAll ( ) ; } if ( ! empty ( $ accountEntities ) ) { $ accounts = [ ] ; foreach ( $ accountEntities as $...
Returns all accounts .
11,130
protected function getApiObject ( $ account , $ locale ) { $ apiObject = $ this -> accountFactory -> createApiEntity ( $ account , $ locale ) ; if ( $ account -> getLogo ( ) ) { $ apiLogo = $ this -> mediaManager -> getById ( $ account -> getLogo ( ) -> getId ( ) , $ locale ) ; $ apiObject -> setLogo ( $ apiLogo ) ; } ...
Takes a account entity and a locale and returns the api object .
11,131
public function create ( $ entityName ) { return new DoctrineListBuilder ( $ this -> em , $ entityName , $ this -> eventDispatcher , $ this -> permissions ) ; }
Creates a new DoctrineListBuilder for the given entity name and returns it .
11,132
public function redirectTrailingSlashOrHtml ( GetResponseForExceptionEvent $ event ) { if ( ! $ event -> getException ( ) instanceof NotFoundHttpException ) { return ; } $ request = $ event -> getRequest ( ) ; $ attributes = $ request -> attributes -> get ( '_sulu' ) ; if ( ! $ attributes ) { return ; } $ prefix = $ at...
Redirect trailing slashes or . html .
11,133
public function redirectPartialMatch ( GetResponseForExceptionEvent $ event ) { if ( ! $ event -> getException ( ) instanceof NotFoundHttpException ) { return ; } $ request = $ event -> getRequest ( ) ; $ attributes = $ event -> getRequest ( ) -> attributes -> get ( '_sulu' ) ; if ( ! $ attributes ) { return ; } $ type...
Redirect partial and redirect matches .
11,134
private function matchUrl ( $ url ) { $ request = Request :: create ( $ url ) ; $ this -> requestAnalyzer -> analyze ( $ request ) ; try { return null !== $ this -> router -> matchRequest ( $ request ) ; } catch ( ResourceNotFoundException $ exception ) { return false ; } }
Returns true if given url exists .
11,135
private function resolveRedirectUrl ( $ redirectUrl , $ requestUri , $ resourceLocatorPrefix ) { $ redirectInfo = $ this -> parseUrl ( $ redirectUrl ) ; $ requestInfo = $ this -> parseUrl ( $ requestUri ) ; $ url = sprintf ( '%s://%s' , $ requestInfo [ 'scheme' ] , $ requestInfo [ 'host' ] ) ; if ( isset ( $ redirectIn...
Resolve the redirect URL appending any additional path data .
11,136
public function postSubmitDocumentParent ( FormEvent $ event ) { $ document = $ event -> getData ( ) ; if ( $ document -> getParent ( ) ) { return ; } $ form = $ event -> getForm ( ) ; $ webspaceKey = $ form -> getConfig ( ) -> getAttribute ( 'webspace_key' ) ; $ parent = $ this -> documentManager -> find ( $ this -> s...
Set the document parent to be the webspace content path when the document has no parent .
11,137
private static function getRegularExpression ( $ portalUrl ) { $ patternUrl = rtrim ( $ portalUrl , '/' ) ; $ patternUrl = preg_quote ( $ patternUrl ) ; $ patternUrl = str_replace ( [ '/' , '\*' ] , [ '\/' , '([^\/.]+)' ] , $ patternUrl ) ; return sprintf ( '/^%s($|([\/].*)|([.].*))$/' , $ patternUrl ) ; }
Returns regular expression to match given portal - url .
11,138
public static function resolve ( $ url , $ portalUrl ) { $ regexp = self :: getRegularExpression ( $ portalUrl ) ; if ( preg_match ( $ regexp , $ url , $ matches ) ) { for ( $ i = 0 , $ countStar = substr_count ( $ portalUrl , '*' ) ; $ i < $ countStar ; ++ $ i ) { $ pos = strpos ( $ portalUrl , '*' ) ; if ( false !== ...
Replaces wildcards with occurrences in the given url .
11,139
public function getConditionGroups ( ) { $ groups = $ this -> entity -> getConditionGroups ( ) ; if ( $ groups ) { $ result = [ ] ; foreach ( $ groups as $ group ) { $ result [ ] = new ConditionGroup ( $ group , $ this -> locale ) ; } return $ result ; } return ; }
Get conditionGroups .
11,140
public function onPostSerialize ( ObjectEvent $ event ) { $ customUrl = $ event -> getObject ( ) ; $ visitor = $ event -> getVisitor ( ) ; if ( ! $ customUrl instanceof CustomUrlDocument ) { return ; } if ( null !== $ customUrl -> getTargetDocument ( ) ) { $ visitor -> addData ( 'targetTitle' , $ customUrl -> getTarget...
Add information to serialized custom - url document .
11,141
private function setData ( Analytics $ analytics , $ webspaceKey , $ data ) { $ analytics -> setTitle ( $ this -> getValue ( $ data , 'title' ) ) ; $ analytics -> setType ( $ this -> getValue ( $ data , 'type' ) ) ; $ analytics -> setContent ( $ this -> getValue ( $ data , 'content' , '' ) ) ; $ analytics -> setAllDoma...
Set data to given key .
11,142
public function setUrlType ( \ Sulu \ Bundle \ ContactBundle \ Entity \ UrlType $ urlType ) { $ this -> urlType = $ urlType ; return $ this ; }
Set urlType .
11,143
protected function getIdFromUrl ( $ url ) { $ fileName = basename ( $ url ) ; $ idParts = explode ( '-' , $ fileName ) ; if ( count ( $ idParts ) < 2 ) { throw new ImageProxyInvalidUrl ( 'No `id` was found in the url' ) ; } $ id = $ idParts [ 0 ] ; if ( preg_match ( '/[^0-9]/' , $ id ) ) { throw new ImageProxyInvalidUr...
return the id of by a given url .
11,144
protected function getFormatFromUrl ( $ url ) { $ path = dirname ( $ url ) ; $ formatParts = array_reverse ( explode ( '/' , $ path ) ) ; if ( count ( $ formatParts ) < 2 ) { throw new ImageProxyInvalidUrl ( 'No `format` was found in the url' ) ; } $ format = $ formatParts [ 1 ] ; return $ format ; }
return the format by a given url .
11,145
private function appendRelation ( QueryBuilder $ queryBuilder , $ relation , $ values , $ operator , $ alias ) { switch ( $ operator ) { case 'or' : return $ this -> appendRelationOr ( $ queryBuilder , $ relation , $ values , $ alias ) ; case 'and' : return $ this -> appendRelationAnd ( $ queryBuilder , $ relation , $ ...
Append tags to query builder with given operator .
11,146
private function appendRelationOr ( QueryBuilder $ queryBuilder , $ relation , $ values , $ alias ) { $ queryBuilder -> leftJoin ( $ relation , $ alias ) -> andWhere ( $ alias . '.id IN (:' . $ alias . ')' ) ; return [ $ alias => $ values ] ; }
Append tags to query builder with or operator .
11,147
private function appendRelationAnd ( QueryBuilder $ queryBuilder , $ relation , $ values , $ alias ) { $ parameter = [ ] ; $ expr = $ queryBuilder -> expr ( ) -> andX ( ) ; $ length = count ( $ values ) ; for ( $ i = 0 ; $ i < $ length ; ++ $ i ) { $ queryBuilder -> leftJoin ( $ relation , $ alias . $ i ) ; $ expr -> a...
Append tags to query builder with and operator .
11,148
public function getStructure ( $ locale ) { return $ this -> contentMapper -> loadShallowStructureByNode ( $ this -> node , $ locale , $ this -> webspace ) ; }
Return the structure which was deleted .
11,149
private function getResourceLocatorFromRequest ( PortalInformation $ portalInformation , Request $ request , $ path ) { $ pathParts = explode ( '/' , $ path ) ; $ fileInfo = explode ( '.' , array_pop ( $ pathParts ) ) ; $ path = rtrim ( implode ( '/' , $ pathParts ) , '/' ) . '/' . $ fileInfo [ 0 ] ; $ formatResult = n...
Returns resource locator and format of current request .
11,150
private function getProvider ( PropertyInterface $ property ) { $ params = $ property -> getParams ( ) ; $ providerAlias = 'pages' ; if ( array_key_exists ( 'provider' , $ params ) ) { $ providerAlias = $ params [ 'provider' ] -> getValue ( ) ; } return $ this -> dataProviderPool -> get ( $ providerAlias ) ; }
Returns provider for given property .
11,151
private function getCurrentPage ( $ pageParameter ) { if ( null === $ this -> requestStack -> getCurrentRequest ( ) ) { return 1 ; } $ page = $ this -> requestStack -> getCurrentRequest ( ) -> get ( $ pageParameter , 1 ) ; if ( $ page < 1 || $ page > PHP_INT_MAX ) { throw new PageOutOfBoundsException ( $ page ) ; } ret...
Determine current page from current request .
11,152
public function createResponse ( ViewHandler $ handler , View $ view , Request $ request , $ format ) { if ( ! $ view -> getData ( ) instanceof ListRepresentation ) { throw new ObjectNotSupportedException ( $ view ) ; } $ viewData = $ view -> getData ( ) ; $ data = new CallbackCollection ( $ viewData -> getData ( ) , [...
Handles response for csv - request .
11,153
public function prepareData ( $ row ) { if ( ! $ row ) { return $ row ; } if ( ! is_array ( $ row ) ) { $ row = $ this -> serializer -> serialize ( $ row , 'array' , SerializationContext :: create ( ) -> setSerializeNull ( true ) ) ; } foreach ( $ row as $ key => $ value ) { if ( $ value instanceof \ DateTime ) { $ row...
The exporter is not able to write DateTime objects into csv . This method converts them to string .
11,154
public function buildPersistence ( array $ interfaces , ContainerBuilder $ container ) { if ( ! empty ( $ interfaces ) ) { $ container -> addCompilerPass ( new ResolveTargetEntitiesPass ( $ interfaces ) ) ; } }
Build persistence adds a ResolveTargetEntitiesPass for the given interfaces .
11,155
public function up ( SessionInterface $ session ) { $ this -> session = $ session ; $ this -> iterateStructures ( true ) ; $ this -> upgradeExternalLinks ( true ) ; }
Migrate the repository up .
11,156
public function down ( SessionInterface $ session ) { $ this -> session = $ session ; $ this -> iterateStructures ( false ) ; $ this -> upgradeExternalLinks ( false ) ; }
Migrate the system down .
11,157
private function upgradeExternalLinks ( $ addScheme ) { foreach ( $ this -> localizationManager -> getLocalizations ( ) as $ localization ) { $ rows = $ this -> session -> getWorkspace ( ) -> getQueryManager ( ) -> createQuery ( sprintf ( 'SELECT * FROM [nt:unstructured] WHERE [%s] = "%s"' , $ this -> propertyEncoder -...
External links are easily updated by fetching all nodes with the external redirect type and add or remove the scheme to the external property .
11,158
private function iterateStructures ( $ addScheme ) { $ properties = [ ] ; $ structureMetadatas = array_merge ( $ this -> structureMetadataFactory -> getStructures ( 'page' ) , $ this -> structureMetadataFactory -> getStructures ( 'snippet' ) ) ; $ structureMetadatas = array_filter ( $ structureMetadatas , function ( St...
Structures are updated according to their xml definition .
11,159
private function findUrlProperties ( StructureMetadata $ structureMetadata , array & $ properties ) { $ structureName = $ structureMetadata -> getName ( ) ; foreach ( $ structureMetadata -> getProperties ( ) as $ property ) { if ( 'url' === $ property -> getType ( ) ) { $ properties [ $ structureName ] [ ] = [ 'propert...
Returns all properties which are a URL field .
11,160
private function upgradeNode ( NodeInterface $ node , $ locale , array $ properties , $ addScheme ) { $ document = $ this -> documentManager -> find ( $ node -> getIdentifier ( ) , $ locale ) ; $ documentLocales = $ this -> documentInspector -> getLocales ( $ document ) ; if ( ! in_array ( $ locale , $ documentLocales ...
Upgrades the node to new URL representation .
11,161
private function upgradeBlockProperty ( BlockMetadata $ blockProperty , array $ components , PropertyValue $ propertyValue , $ addScheme ) { $ componentNames = array_map ( function ( $ item ) { return $ item [ 'component' ] -> getName ( ) ; } , $ components ) ; $ value = $ propertyValue -> getValue ( ) ; foreach ( $ va...
Upgrades the given block property to the new URL representation .
11,162
private function upgradeUrl ( & $ value ) { if ( ! empty ( $ value ) && false === strpos ( $ value , 'http://' ) && false === strpos ( $ value , 'https://' ) && false === strpos ( $ value , 'ftp://' ) && false === strpos ( $ value , 'ftps://' ) && false === strpos ( $ value , 'mailto:' ) && false === strpos ( $ value ,...
Upgrades the given URL to the new representation .
11,163
public function handleScheduleRename ( PersistEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ event -> getOption ( 'auto_name' ) || ! $ document instanceof AutoNameBehavior || $ event -> getOption ( 'auto_name_locale' ) !== $ event -> getLocale ( ) || ! $ event -> hasNode ( ) || $ event -> getNode ...
Renames node if necessary .
11,164
private function getName ( AutoNameBehavior $ document , NodeInterface $ parentNode , $ autoRename = true , NodeInterface $ node = null ) { $ title = $ document -> getTitle ( ) ; if ( ! $ title ) { throw new DocumentManagerException ( sprintf ( 'Document has no title (title is required for auto name behavior): %s)' , D...
Returns unique name for given document and nodes .
11,165
private function handleMoveCopy ( MoveEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ document instanceof AutoNameBehavior ) { return ; } $ destId = $ event -> getDestId ( ) ; $ node = $ this -> registry -> getNodeForDocument ( $ document ) ; $ destNode = $ this -> nodeManager -> find ( $ destId ) ...
Resolve the destination name on move and copy events .
11,166
public function onPostSerialize ( ObjectEvent $ event ) { $ object = $ event -> getObject ( ) ; if ( $ object instanceof ApiWrapper ) { $ object = $ object -> getEntity ( ) ; } if ( ! $ object instanceof AuditableInterface && ! $ object instanceof LocalizedAuditableBehavior ) { return ; } $ visitor = $ event -> getVisi...
Adds the hash of the given object to its serialization .
11,167
private function getSystemCollections ( ) { if ( ! $ this -> systemCollections ) { if ( ! $ this -> cache -> isFresh ( ) ) { $ systemCollections = $ this -> buildSystemCollections ( $ this -> locale , $ this -> getUserId ( ) ) ; $ this -> cache -> write ( $ systemCollections ) ; } $ this -> systemCollections = $ this -...
Returns system collections .
11,168
private function getUserId ( ) { if ( ! $ this -> tokenProvider || null === ( $ token = $ this -> tokenProvider -> getToken ( ) ) ) { return ; } if ( ! $ token -> getUser ( ) instanceof UserInterface ) { return ; } return $ token -> getUser ( ) -> getId ( ) ; }
Returns current user .
11,169
private function buildSystemCollections ( $ locale , $ userId ) { $ root = $ this -> getOrCreateRoot ( SystemCollectionManagerInterface :: COLLECTION_KEY , 'System' , $ locale , $ userId ) ; $ collections = [ 'root' => $ root -> getId ( ) ] ; $ collections = array_merge ( $ collections , $ this -> iterateOverCollection...
Go thru configuration and build all system collections .
11,170
private function iterateOverCollections ( $ children , $ userId , $ parent = null , $ namespace = '' ) { $ format = ( '' !== $ namespace ? '%s.%s' : '%s%s' ) ; $ collections = [ ] ; foreach ( $ children as $ collectionKey => $ collectionItem ) { $ key = sprintf ( $ format , $ namespace , $ collectionKey ) ; $ collectio...
Iterates over an array of children collections creates them . This function is recursive!
11,171
private function getOrCreateRoot ( $ namespace , $ title , $ locale , $ userId , $ parent = null ) { if ( null !== ( $ collection = $ this -> collectionManager -> getByKey ( $ namespace , $ locale ) ) ) { $ collection -> setTitle ( $ title ) ; return $ collection ; } return $ this -> createCollection ( $ title , $ name...
Finds or create a new system - collection namespace .
11,172
private function getOrCreateCollection ( $ key , $ localizedTitles , $ userId , $ parent ) { $ locales = array_keys ( $ localizedTitles ) ; $ firstLocale = array_shift ( $ locales ) ; $ collection = $ this -> collectionManager -> getByKey ( $ key , $ firstLocale ) ; if ( null === $ collection ) { $ collection = $ this ...
Finds or create a new system - collection .
11,173
public function getExportData ( ) { $ snippets = $ this -> getSnippets ( ) ; $ snippetsData = [ ] ; $ progress = new ProgressBar ( $ this -> output , count ( $ snippets ) ) ; $ progress -> start ( ) ; foreach ( $ snippets as $ snippet ) { $ contentData = $ this -> getContentData ( $ snippet , $ this -> exportLocale ) ;...
Returns all data that we need to create a xliff - File .
11,174
public function registerDocument ( $ document , NodeInterface $ node , $ locale ) { $ oid = $ this -> getObjectIdentifier ( $ document ) ; $ uuid = $ node -> getIdentifier ( ) ; $ this -> validateDocumentRegistration ( $ document , $ locale , $ node , $ oid , $ uuid ) ; $ this -> documentMap [ $ oid ] = $ document ; $ ...
Register a document .
11,175
public function hasDocument ( $ document ) { $ oid = $ this -> getObjectIdentifier ( $ document ) ; return isset ( $ this -> documentMap [ $ oid ] ) ; }
Return true if the document is managed .
11,176
public function hasNode ( NodeInterface $ node , $ locale ) { return array_key_exists ( $ this -> getNodeLocaleKey ( $ node -> getIdentifier ( ) , $ locale ) , $ this -> nodeDocumentMap ) ; }
Return true if the node is managed .
11,177
public function deregisterDocument ( $ document ) { $ oid = $ this -> getObjectIdentifier ( $ document ) ; $ this -> assertDocumentExists ( $ document ) ; $ nodeIdentifier = $ this -> documentNodeMap [ $ oid ] ; $ locale = $ this -> documentLocaleMap [ $ oid ] ; unset ( $ this -> nodeMap [ $ nodeIdentifier ] ) ; unset ...
Remove all references to the given document and its associated node .
11,178
public function getNodeForDocument ( $ document ) { $ oid = $ this -> getObjectIdentifier ( $ document ) ; $ this -> assertDocumentExists ( $ document ) ; return $ this -> nodeMap [ $ this -> documentNodeMap [ $ oid ] ] ; }
Return the node for the given managed document .
11,179
public function getLocaleForDocument ( $ document ) { $ oid = $ this -> getObjectIdentifier ( $ document ) ; $ this -> assertDocumentExists ( $ document ) ; return $ this -> documentLocaleMap [ $ oid ] ; }
Return the current locale for the given document .
11,180
public function getOriginalLocaleForDocument ( $ document ) { $ this -> assertDocumentExists ( $ document ) ; if ( $ document instanceof LocaleBehavior ) { return $ document -> getOriginalLocale ( ) ? : $ document -> getLocale ( ) ; } return $ this -> getLocaleForDocument ( $ document ) ; }
Return the original locale for the document .
11,181
public function getDocumentForNode ( NodeInterface $ node , $ locale ) { $ identifier = $ node -> getIdentifier ( ) ; $ this -> assertNodeExists ( $ identifier ) ; return $ this -> nodeDocumentMap [ $ this -> getNodeLocaleKey ( $ node -> getIdentifier ( ) , $ locale ) ] ; }
Return the document for the given managed node .
11,182
private function validateDocumentRegistration ( $ document , $ locale , NodeInterface $ node , $ oid , $ uuid ) { if ( null === $ uuid ) { throw new DocumentManagerException ( sprintf ( 'Node "%s" of type "%s" has no UUID. Only referencable nodes can be registered by the document manager' , $ node -> getPath ( ) , $ no...
Ensure that the document is not already registered and that the node has a UUID .
11,183
protected function getFilterQuery ( $ locale ) { $ qb = $ this -> createQueryBuilder ( 'filter' ) -> addSelect ( 'conditionGroups' ) -> addSelect ( 'translations' ) -> addSelect ( 'conditions' ) -> leftJoin ( 'filter.translations' , 'translations' , 'WITH' , 'translations.locale = :locale' ) -> leftJoin ( 'filter.condi...
Returns the query for filters .
11,184
public function deleteByIds ( $ ids ) { $ qb = $ this -> createQueryBuilder ( 'filter' ) -> delete ( ) -> where ( 'filter.id IN (:ids)' ) -> setParameter ( 'ids' , $ ids ) ; $ qb -> getQuery ( ) -> execute ( ) ; }
Deletes multiple filters .
11,185
public function getReferences ( $ uuid ) { $ session = $ this -> sessionManager -> getSession ( ) ; $ node = $ session -> getNodeByIdentifier ( $ uuid ) ; return iterator_to_array ( $ node -> getReferences ( ) ) ; }
Return the nodes which refer to the structure with the given UUID .
11,186
public function getSnippetsByUuids ( array $ uuids , $ locale , $ loadGhostContent = false ) { $ snippets = [ ] ; foreach ( $ uuids as $ uuid ) { try { $ snippet = $ this -> documentManager -> find ( $ uuid , $ locale , [ 'load_ghost_content' => $ loadGhostContent , ] ) ; $ snippets [ ] = $ snippet ; } catch ( Document...
Return snippets identified by the given UUIDs .
11,187
public function getSnippets ( $ locale , $ type = null , $ offset = null , $ max = null , $ search = null , $ sortBy = null , $ sortOrder = null ) { $ query = $ this -> getSnippetsQuery ( $ locale , $ type , $ offset , $ max , $ search , $ sortBy , $ sortOrder ) ; $ documents = $ this -> documentManager -> createQuery ...
Return snippets .
11,188
public function getSnippetsAmount ( $ locale , $ type = null , $ search = null , $ sortBy = null , $ sortOrder = null ) { $ query = $ this -> getSnippetsQuery ( $ locale , $ type , null , null , $ search , $ sortBy , $ sortOrder ) ; $ result = $ query -> execute ( ) ; return count ( iterator_to_array ( $ result -> getR...
Return snippets amount .
11,189
public function copyLocale ( $ uuid , $ userId , $ srcLocale , $ destLocales ) { return $ this -> contentMapper -> copyLanguage ( $ uuid , $ userId , null , $ srcLocale , $ destLocales , Structure :: TYPE_SNIPPET ) ; }
Copy snippet from src - locale to dest - locale .
11,190
private function getSnippetsQuery ( $ locale , $ type = null , $ offset = null , $ max = null , $ search = null , $ sortBy = null , $ sortOrder = null ) { $ snippetNode = $ this -> sessionManager -> getSnippetNode ( $ type ) ; $ workspace = $ this -> sessionManager -> getSession ( ) -> getWorkspace ( ) ; $ queryManager...
Return snippets load query .
11,191
public function cgetAction ( Request $ request , $ uuid ) { $ locale = $ this -> getRequestParameter ( $ request , 'language' , true ) ; $ document = $ this -> get ( 'sulu_document_manager.document_manager' ) -> find ( $ uuid , $ request -> query -> get ( 'language' ) ) ; $ versions = array_reverse ( array_filter ( $ d...
Returns the versions for the node with the given UUID .
11,192
private function findOrCreateCategoryTranslation ( CategoryInterface $ category , CategoryWrapper $ categoryWrapper , $ locale ) { $ translationEntity = $ category -> findTranslationByLocale ( $ locale ) ; if ( ! $ translationEntity ) { $ translationEntity = $ this -> categoryTranslationRepository -> createNew ( ) ; $ ...
Returns category - translation or create a new one .
11,193
public function getApiObject ( $ category , $ locale ) { if ( $ category instanceof CategoryWrapper ) { $ category = $ category -> getEntity ( ) ; } if ( ! $ category instanceof CategoryInterface ) { return ; } return new CategoryWrapper ( $ category , $ locale ) ; }
Returns an API - Object for a given category - entity . The API - Object wraps the entity and provides neat getters and setters . If the given object is already an API - object the associated entity is used for wrapping .
11,194
public function getApiObjects ( $ entities , $ locale ) { return array_map ( function ( $ entity ) use ( $ locale ) { return $ this -> getApiObject ( $ entity , $ locale ) ; } , $ entities ) ; }
Returns an array of API - Objects for a given array of category - entities . The returned array can contain null - values if the given entities are not valid .
11,195
public function getQueryBuilderWithoutSecurity ( QueryBuilder $ queryBuilder ) { $ queryBuilder -> addSelect ( 'fileVersion' ) -> addSelect ( 'file' ) -> addSelect ( 'media' ) -> addSelect ( 'collection' ) -> leftJoin ( 'd.fileVersion' , 'fileVersion' ) -> leftJoin ( 'fileVersion.file' , 'file' ) -> leftJoin ( 'file.me...
Returns query - builder to find file - version - meta without permissions .
11,196
private function buildPropertiesSelect ( $ locale , & $ additionalFields ) { foreach ( $ this -> propertiesConfig as $ parameter ) { $ alias = $ parameter -> getName ( ) ; $ propertyName = $ parameter -> getValue ( ) ; if ( false !== strpos ( $ propertyName , '.' ) ) { $ parts = explode ( '.' , $ propertyName ) ; $ thi...
build select for properties .
11,197
private function buildPropertySelect ( $ alias , $ propertyName , $ locale , & $ additionalFields ) { foreach ( $ this -> structureManager -> getStructures ( static :: $ structureType ) as $ structure ) { if ( $ structure -> hasProperty ( $ propertyName ) ) { $ property = $ structure -> getProperty ( $ propertyName ) ;...
build select for single property .
11,198
private function buildExtensionSelect ( $ alias , $ extension , $ propertyName , $ locale , & $ additionalFields ) { $ extension = $ this -> extensionManager -> getExtension ( 'all' , $ extension ) ; $ additionalFields [ $ locale ] [ ] = [ 'name' => $ alias , 'extension' => $ extension , 'property' => $ propertyName , ...
build select for extension property .
11,199
private function buildDatasourceWhere ( ) { $ dataSource = $ this -> getConfig ( 'dataSource' ) ; $ includeSubFolders = $ this -> getConfig ( 'includeSubFolders' , false ) ; $ sqlFunction = false !== $ includeSubFolders && 'false' !== $ includeSubFolders ? 'ISDESCENDANTNODE' : 'ISCHILDNODE' ; $ node = $ this -> session...
build datasource where clause .