idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
11,300
protected function assignSortFields ( $ queryBuilder ) { if ( 0 === count ( $ this -> sortFields ) ) { $ queryBuilder -> addOrderBy ( $ this -> idField -> getSelect ( ) , 'ASC' ) ; } foreach ( $ this -> sortFields as $ index => $ sortField ) { $ statement = $ this -> getSelectAs ( $ sortField ) ; if ( ! $ this -> hasSe...
Assigns ORDER BY clauses to querybuilder .
11,301
protected function assignGroupBy ( $ queryBuilder ) { if ( ! empty ( $ this -> groupByFields ) ) { foreach ( $ this -> groupByFields as $ fields ) { $ queryBuilder -> groupBy ( $ fields -> getSelect ( ) ) ; } } }
Sets group by fields to querybuilder .
11,302
protected function getJoins ( ) { $ joins = [ ] ; $ fields = array_merge ( $ this -> sortFields , $ this -> selectFields , $ this -> searchFields , $ this -> expressionFields ) ; foreach ( $ fields as $ field ) { $ joins = array_merge ( $ joins , $ field -> getJoins ( ) ) ; } return $ joins ; }
Returns all the joins required for the query .
11,303
protected function getAllFields ( $ onlyReturnFilterFields = false ) { $ fields = array_merge ( $ this -> searchFields , $ this -> sortFields , $ this -> getUniqueExpressionFieldDescriptors ( $ this -> expressions ) ) ; if ( true !== $ onlyReturnFilterFields ) { $ fields = array_merge ( $ fields , $ this -> selectField...
Returns all DoctrineFieldDescriptors that were passed to list builder .
11,304
protected function createSubQueryBuilder ( $ select = null ) { if ( ! $ select ) { $ select = $ this -> getSelectAs ( $ this -> idField ) ; } $ filterFields = $ this -> getAllFields ( true ) ; $ entityNames = $ this -> getEntityNamesOfFieldDescriptors ( $ filterFields ) ; $ addJoins = $ this -> getNecessaryJoins ( $ en...
Creates a query - builder for sub - selecting ID s .
11,305
protected function getNecessaryJoins ( $ necessaryEntityNames ) { $ addJoins = [ ] ; foreach ( $ this -> getAllFields ( ) as $ key => $ field ) { if ( ( $ field instanceof DoctrineFieldDescriptor || $ field instanceof DoctrineJoinDescriptor ) && false !== array_search ( $ field -> getEntityName ( ) , $ necessaryEntityN...
Function returns all necessary joins for filtering result .
11,306
protected function getEntityNamesOfFieldDescriptors ( $ filterFields ) { $ fields = [ ] ; foreach ( $ filterFields as $ field ) { $ fields = array_merge ( $ fields , $ field -> getJoins ( ) ) ; if ( $ field instanceof DoctrineFieldDescriptor || $ field instanceof DoctrineJoinDescriptor ) { $ fields [ ] = $ field ; } } ...
Returns array of field - descriptor aliases .
11,307
protected function createQueryBuilder ( $ joins = null ) { $ this -> queryBuilder = $ this -> em -> createQueryBuilder ( ) -> from ( $ this -> entityName , $ this -> encodeAlias ( $ this -> entityName ) ) ; $ this -> assignJoins ( $ this -> queryBuilder , $ joins ) ; if ( null !== $ this -> ids ) { $ this -> in ( $ thi...
Creates Querybuilder .
11,308
protected function assignJoins ( QueryBuilder $ queryBuilder , array $ joins = null ) { if ( null === $ joins ) { $ joins = $ this -> getJoins ( ) ; } foreach ( $ joins as $ entity => $ join ) { switch ( $ join -> getJoinMethod ( ) ) { case DoctrineJoinDescriptor :: JOIN_METHOD_LEFT : $ queryBuilder -> leftJoin ( $ joi...
Adds joins to querybuilder .
11,309
protected function getUniqueExpressionFieldDescriptors ( array $ expressions ) { if ( 0 === count ( $ this -> expressionFields ) ) { $ descriptors = [ ] ; $ uniqueNames = array_unique ( $ this -> getAllFieldNames ( $ expressions ) ) ; foreach ( $ uniqueNames as $ uniqueName ) { $ descriptors [ ] = $ this -> fieldDescri...
Returns an array of unique expression field descriptors .
11,310
protected function getAllFieldNames ( $ expressions ) { $ fieldNames = [ ] ; foreach ( $ expressions as $ expression ) { if ( $ expression instanceof ConjunctionExpressionInterface ) { $ fieldNames = array_merge ( $ fieldNames , $ expression -> getFieldNames ( ) ) ; } elseif ( $ expression instanceof BasicExpressionInt...
Returns all fieldnames used in the expressions .
11,311
private function getSelectAs ( DoctrineFieldDescriptorInterface $ field , $ hidden = false ) { $ select = $ field -> getSelect ( ) . ' AS ' ; if ( $ hidden ) { $ select .= 'HIDDEN ' ; } return $ select . $ field -> getName ( ) ; }
Get select as from doctrine field descriptor .
11,312
public function handleReorder ( ReorderEvent $ event ) { $ this -> nodeHelper -> reorder ( $ event -> getNode ( ) , $ event -> getDestId ( ) ) ; }
Handle the reorder operation .
11,313
public function cgetAction ( Request $ request ) { $ restHelper = $ this -> get ( 'sulu_core.doctrine_rest_helper' ) ; $ factory = $ this -> get ( 'sulu_core.doctrine_list_builder_factory' ) ; $ listBuilder = $ factory -> create ( $ this -> getTargetGroupRepository ( ) -> getClassName ( ) ) ; $ fieldDescriptors = $ thi...
Returns list of target - groups .
11,314
public function getAction ( $ id ) { $ findCallback = function ( $ id ) { $ targetGroup = $ this -> getTargetGroupRepository ( ) -> find ( $ id ) ; return $ targetGroup ; } ; $ view = $ this -> responseGetById ( $ id , $ findCallback ) ; return $ this -> handleView ( $ view ) ; }
Returns a target group by id .
11,315
public function postAction ( Request $ request ) { $ targetGroup = $ this -> deserializeData ( $ request -> getContent ( ) ) ; $ targetGroup = $ this -> getTargetGroupRepository ( ) -> save ( $ targetGroup ) ; $ this -> getEntityManager ( ) -> flush ( ) ; return $ this -> handleView ( $ this -> view ( $ targetGroup ) )...
Handle post request for target group .
11,316
public function putAction ( Request $ request , $ id ) { $ jsonData = $ request -> getContent ( ) ; $ data = json_decode ( $ jsonData , true ) ; $ data [ 'id' ] = $ id ; $ targetGroup = $ this -> deserializeData ( json_encode ( $ data ) ) ; $ targetGroup = $ this -> getTargetGroupRepository ( ) -> save ( $ targetGroup ...
Handle put request for target group .
11,317
public function deleteAction ( $ id ) { $ targetGroup = $ this -> retrieveTargetGroupById ( $ id ) ; $ this -> getEntityManager ( ) -> remove ( $ targetGroup ) ; $ this -> getEntityManager ( ) -> flush ( ) ; return $ this -> handleView ( $ this -> view ( null , 204 ) ) ; }
Handle delete request for target group .
11,318
public function cdeleteAction ( Request $ request ) { $ idsData = $ request -> get ( 'ids' ) ; $ ids = explode ( ',' , $ idsData ) ; if ( ! count ( $ ids ) ) { throw new MissingParameterException ( 'TargetGroupController' , 'ids' ) ; } $ targetGroups = $ this -> getTargetGroupRepository ( ) -> findById ( $ ids ) ; fore...
Handle multiple delete requests for target groups .
11,319
private function deserializeData ( $ data ) { $ result = $ this -> get ( 'jms_serializer' ) -> deserialize ( $ data , $ this -> getTargetGroupRepository ( ) -> getClassName ( ) , 'json' , DeserializationContext :: create ( ) -> setSerializeNull ( true ) ) ; return $ result ; }
Deserializes string into TargetGroup object .
11,320
private function retrieveTargetGroupById ( $ id ) { $ targetGroup = $ this -> getTargetGroupRepository ( ) -> find ( $ id ) ; if ( ! $ targetGroup ) { throw new EntityNotFoundException ( $ this -> getTargetGroupRepository ( ) -> getClassName ( ) , $ id ) ; } return $ targetGroup ; }
Returns target group by id . Throws an exception if not found .
11,321
private function cleanUpFileName ( $ fileName , $ locale , $ extension ) { $ pathInfo = pathinfo ( $ fileName ) ; $ cleanedFileName = $ this -> get ( 'sulu.content.path_cleaner' ) -> cleanup ( $ pathInfo [ 'filename' ] , $ locale ) ; if ( $ extension ) { $ cleanedFileName .= '.' . $ extension ; } return $ cleanedFileNa...
Cleaned up filename .
11,322
public function loadClassMetadata ( LoadClassMetadataEventArgs $ event ) { $ metadata = $ event -> getClassMetadata ( ) ; $ reflection = $ metadata -> getReflectionClass ( ) ; if ( null !== $ reflection && $ reflection -> implementsInterface ( 'Sulu\Component\Persistence\Model\TimestampableInterface' ) ) { if ( ! $ met...
Load the class data mapping the created and changed fields to datetime fields .
11,323
private function handleTimestamp ( LifecycleEventArgs $ event ) { $ entity = $ event -> getObject ( ) ; if ( ! $ entity instanceof TimestampableInterface ) { return ; } $ meta = $ event -> getObjectManager ( ) -> getClassMetadata ( get_class ( $ entity ) ) ; $ created = $ meta -> getFieldValue ( $ entity , self :: CREA...
Set the timestamps . If created is NULL then set it . Always set the changed field .
11,324
public function cgetAction ( ) { $ webspaceManager = $ this -> get ( 'sulu_core.webspace.webspace_manager' ) ; $ localizations = [ ] ; $ locales = [ ] ; foreach ( $ webspaceManager -> getWebspaceCollection ( ) as $ webspace ) { $ i = 0 ; foreach ( $ webspace -> getAllLocalizations ( ) as $ localization ) { if ( ! in_ar...
Returns all languages in admin .
11,325
private function getExcerptStructure ( $ locale = null ) { if ( null === $ locale ) { $ locale = $ this -> languageCode ; } $ excerptStructure = $ this -> structureManager -> getStructure ( self :: EXCERPT_EXTENSION_NAME ) ; $ excerptStructure -> setLanguageCode ( $ locale ) ; return $ excerptStructure ; }
Returns and caches excerpt - structure .
11,326
private function initProperties ( $ locale ) { $ this -> properties = [ ] ; foreach ( $ this -> getExcerptStructure ( $ locale ) -> getProperties ( ) as $ property ) { $ this -> properties [ ] = $ property -> getName ( ) ; } }
Initiates structure and properties .
11,327
protected function setDocumentSettings ( BasePageDocument $ document , $ format , $ data , $ overrideSettings ) { if ( 'true' !== $ overrideSettings ) { return ; } foreach ( $ data as $ key => $ property ) { $ setter = 'set' . ucfirst ( $ key ) ; if ( in_array ( $ key , self :: $ excludedSettings ) || ! method_exists (...
Set all Settings for the given documents and import them . Import property - o must be set to true .
11,328
protected function getSetterValue ( $ key , $ value ) { if ( empty ( $ value ) ) { return ; } switch ( $ key ) { case 'redirectTarget' : $ value = $ this -> documentManager -> find ( $ value ) ; break ; case 'permissions' : $ value = json_decode ( $ value , true ) ; break ; case 'navigationContexts' : $ value = json_de...
Prepare the settings value for the respective setter .
11,329
protected function importExtension ( ExportExtensionInterface $ extension , $ extensionKey , NodeInterface $ node , $ data , $ webspaceKey , $ locale , $ format ) { $ extensionData = [ ] ; foreach ( $ extension -> getImportPropertyNames ( ) as $ propertyName ) { $ value = $ this -> getParser ( $ format ) -> getProperty...
Importing the Extensions like SEO - and Excerption - Tab .
11,330
private function generateUrl ( $ properties , $ parentUuid , $ webspaceKey , $ locale , $ format , $ data ) { $ rlpParts = [ ] ; foreach ( $ properties as $ property ) { $ rlpParts [ ] = $ this -> getParser ( $ format ) -> getPropertyData ( $ property -> getName ( ) , $ data , $ property -> getContentTypeName ( ) ) ; }...
Generates a url by given strategy and property .
11,331
private function getAttributes ( $ tag ) { if ( ! preg_match_all ( self :: ATTRIBUTE_REGEX , $ tag , $ matches ) ) { return [ ] ; } $ attributes = [ ] ; for ( $ i = 0 , $ length = count ( $ matches [ 'name' ] ) ; $ i < $ length ; ++ $ i ) { $ value = $ matches [ 'value' ] [ $ i ] ; if ( 'true' === $ value || 'false' ==...
Returns attributes of given html - tag .
11,332
public static function removeComposerLockFromGitIgnore ( ) { if ( ! file_exists ( static :: GIT_IGNORE_FILE ) ) { return ; } $ gitignore = file_get_contents ( static :: GIT_IGNORE_FILE ) ; $ gitignore = str_replace ( "composer.lock\n" , '' , $ gitignore ) ; file_put_contents ( static :: GIT_IGNORE_FILE , $ gitignore ) ...
Removes the composer . lock file from . gitignore because we don t want the composer . lock to be included in our repositories but they should be included when developing specific project .
11,333
public static function removePackageLockJsonFromGitIgnore ( ) { if ( ! file_exists ( static :: GIT_IGNORE_FILE ) ) { return ; } $ gitignore = file_get_contents ( static :: GIT_IGNORE_FILE ) ; $ gitignore = str_replace ( "package-lock.json\n" , '' , $ gitignore ) ; file_put_contents ( static :: GIT_IGNORE_FILE , $ gitig...
Removes the package - lock . json file from . gitignore because we don t want the package - lock . json to be included in our repositories but they should be included when developing specific project .
11,334
private function upgradeWebspace ( Webspace $ webspace ) { $ sessionManager = $ this -> container -> get ( 'sulu.phpcr.session' ) ; $ node = $ sessionManager -> getContentNode ( $ webspace -> getKey ( ) ) ; foreach ( $ webspace -> getAllLocalizations ( ) as $ localization ) { $ locale = $ localization -> getLocale ( ) ...
Upgrade a single webspace .
11,335
private function upgradeNode ( NodeInterface $ node , $ propertyName , $ locale ) { foreach ( $ node -> getNodes ( ) as $ child ) { $ this -> upgradeNode ( $ child , $ propertyName , $ locale ) ; } if ( false === $ node -> getPropertyValueWithDefault ( $ propertyName , false ) ) { return ; } $ shadowLocale = $ node -> ...
Upgrade a single node .
11,336
private function getTags ( NodeInterface $ node , $ locale ) { return $ node -> getPropertyValueWithDefault ( sprintf ( self :: TAGS_PROPERTY , $ locale ) , [ ] ) ; }
Returns tags of given node and locale .
11,337
private function getCategories ( NodeInterface $ node , $ locale ) { return $ node -> getPropertyValueWithDefault ( sprintf ( self :: CATEGORIES_PROPERTY , $ locale ) , [ ] ) ; }
Returns categories of given node and locale .
11,338
private function getNavigationContext ( NodeInterface $ node , $ locale ) { return $ node -> getPropertyValueWithDefault ( sprintf ( self :: NAVIGATION_CONTEXT_PROPERTY , $ locale ) , [ ] ) ; }
Returns navigation context of given node and locale .
11,339
public function configAction ( ) : Response { $ user = $ this -> tokenStorage -> getToken ( ) -> getUser ( ) ; $ contact = $ this -> contactManager -> getById ( $ user -> getContact ( ) -> getId ( ) , $ user -> getLocale ( ) ) ; $ view = View :: create ( [ 'sulu_admin' => [ 'endpoints' => [ 'metadata' => $ this -> urlG...
Returns all the configuration for the admin interface .
11,340
private function buildUrls ( Portal $ portal , Environment $ environment , Url $ url , $ segments , $ urlAddress ) { if ( $ url -> getLanguage ( ) ) { $ language = $ url -> getLanguage ( ) ; $ country = $ url -> getCountry ( ) ; $ locale = $ language . ( $ country ? '_' . $ country : '' ) ; $ this -> buildUrlFullMatch ...
Builds the URLs for the portal which are not a redirect .
11,341
private function generateUrlAddress ( $ pattern , $ replacers ) { foreach ( $ replacers as $ replacer => $ value ) { $ pattern = $ this -> urlReplacer -> replace ( $ pattern , $ replacer , $ value ) ; } return $ pattern ; }
Replaces the given values in the pattern .
11,342
public function findAllGroups ( ) { try { $ qb = $ this -> createQueryBuilder ( 'grp' ) ; $ query = $ qb -> getQuery ( ) ; $ result = $ query -> getResult ( ) ; return $ result ; } catch ( NoResultException $ ex ) { return ; } }
Searches for all roles .
11,343
private function getImageUrl ( $ data , $ locale ) { if ( $ data instanceof MediaSelectionContainer ) { $ medias = $ data -> getData ( 'de' ) ; } else { if ( ! isset ( $ data [ 'ids' ] ) ) { throw new \ RuntimeException ( sprintf ( 'Was expecting media value to contain array key "ids", got: "%s"' , print_r ( $ data , t...
Returns the url for the image .
11,344
protected function documentToStructure ( BasePageDocument $ document ) { $ structure = $ this -> inspector -> getStructureMetadata ( $ document ) ; $ documentAlias = $ this -> inspector -> getMetadata ( $ document ) -> getAlias ( ) ; $ structureBridge = $ this -> structureManager -> wrapStructure ( $ documentAlias , $ ...
Return a structure bridge corresponding to the given document .
11,345
public function redirectAction ( Request $ request , $ id ) { $ locale = $ this -> getRequestParameter ( $ request , 'locale' , true ) ; $ format = $ this -> getRequestParameter ( $ request , 'format' ) ; $ media = $ this -> container -> get ( 'sulu_media.media_manager' ) -> getById ( $ id , $ locale ) ; if ( null === ...
Redirects to format or original url .
11,346
public function putAction ( Request $ request , $ key ) { $ webspaceKey = $ this -> getRequestParameter ( $ request , 'webspace' , true ) ; $ this -> get ( 'sulu_security.security_checker' ) -> checkPermission ( new SecurityCondition ( SnippetAdmin :: getDefaultSnippetsSecurityContext ( $ webspaceKey ) ) , PermissionTy...
Put default action .
11,347
public function deleteAction ( Request $ request , $ key ) { $ webspaceKey = $ this -> getRequestParameter ( $ request , 'webspace' , true ) ; $ this -> get ( 'sulu_security.security_checker' ) -> checkPermission ( new SecurityCondition ( SnippetAdmin :: getDefaultSnippetsSecurityContext ( $ webspaceKey ) ) , Permissio...
Delete default action .
11,348
public function delete ( ) { $ delete = function ( $ id ) { $ user = $ this -> userRepository -> findUserById ( $ id ) ; if ( ! $ user ) { throw new EntityNotFoundException ( $ this -> userRepository -> getClassName ( ) , $ id ) ; } $ this -> em -> remove ( $ user ) ; $ this -> em -> flush ( ) ; } ; return $ delete ; }
Deletes a user with the given id .
11,349
public function isUsernameUnique ( $ username ) { if ( $ username ) { try { $ this -> userRepository -> findUserByUsername ( $ username ) ; } catch ( NoResultException $ exc ) { return true ; } } return false ; }
Checks if a username is unique Null and empty will always return false .
11,350
public function isEmailUnique ( $ email ) { if ( $ email ) { try { $ this -> userRepository -> findUserByEmail ( $ email ) ; } catch ( NoResultException $ exc ) { return true ; } } return false ; }
Checks if an email - adress is unique Null and empty will always return false .
11,351
public function processUserRoles ( UserInterface $ user , $ userRoles ) { $ get = function ( $ entity ) { return $ entity -> getId ( ) ; } ; $ delete = function ( $ userRole ) use ( $ user ) { $ user -> removeUserRole ( $ userRole ) ; $ this -> em -> remove ( $ userRole ) ; } ; $ update = function ( $ userRole , $ user...
Process all user roles from request .
11,352
protected function processUserGroups ( UserInterface $ user , $ userGroups ) { $ get = function ( $ entity ) { return $ entity -> getId ( ) ; } ; $ delete = function ( $ userGroup ) use ( $ user ) { $ user -> removeUserGroup ( $ userGroup ) ; $ this -> em -> remove ( $ userGroup ) ; } ; $ update = function ( $ userGrou...
Process all user groups from request .
11,353
private function updateUserRole ( UserRole $ userRole , $ userRoleData ) { $ role = $ this -> roleRepository -> findRoleById ( $ userRoleData [ 'role' ] [ 'id' ] ) ; if ( ! $ role ) { throw new EntityNotFoundException ( $ this -> roleRepository -> getClassName ( ) , $ userRole [ 'role' ] [ 'id' ] ) ; } $ userRole -> se...
Updates an existing UserRole with the given data .
11,354
private function addUserRole ( UserInterface $ user , $ userRoleData ) { $ alreadyContains = false ; $ role = $ this -> roleRepository -> findRoleById ( $ userRoleData [ 'role' ] [ 'id' ] ) ; if ( ! $ role ) { throw new EntityNotFoundException ( $ this -> roleRepository -> getClassName ( ) , $ userRoleData [ 'role' ] [...
Adds a new UserRole to the given user .
11,355
private function addUserGroup ( UserInterface $ user , $ userGroupData ) { $ group = $ this -> groupRepository -> findGroupById ( $ userGroupData [ 'group' ] [ 'id' ] ) ; if ( ! $ group ) { throw new EntityNotFoundException ( $ this -> groupRepository -> getClassName ( ) , $ userGroupData [ 'group' ] [ 'id' ] ) ; } $ u...
Adds a new UserGroup to the given user .
11,356
private function updateUserGroup ( UserGroup $ userGroup , $ userGroupData ) { $ group = $ this -> groupRepository -> findGroupById ( $ userGroupData [ 'group' ] [ 'id' ] ) ; if ( ! $ group ) { throw new EntityNotFoundException ( $ this -> groupRepository -> getClassName ( ) , $ userGroup [ 'group' ] [ 'id' ] ) ; } $ u...
Updates an existing UserGroup with the given data .
11,357
private function getContact ( $ id ) { $ contact = $ this -> contactManager -> findById ( $ id ) ; if ( ! $ contact ) { throw new EntityNotFoundException ( $ this -> contactManager -> getContactEntityName ( ) , $ id ) ; } return $ contact ; }
Returns the contact with the given id .
11,358
private function processEmail ( UserInterface $ user , $ email , $ contact = null ) { if ( $ contact ) { if ( null === $ email && array_key_exists ( 'emails' , $ contact ) && count ( $ contact [ 'emails' ] ) > 0 && $ this -> isEmailUnique ( $ contact [ 'emails' ] [ 0 ] [ 'email' ] ) ) { $ email = $ contact [ 'emails' ]...
Processes the email and adds it to the user .
11,359
public function copyUserLocaleToRequest ( GetResponseEvent $ event ) { $ token = $ this -> tokenStorage -> getToken ( ) ; if ( ! $ token ) { return ; } $ user = $ token -> getUser ( ) ; if ( ! $ user instanceof UserInterface ) { return ; } $ locale = $ user -> getLocale ( ) ; $ event -> getRequest ( ) -> setLocale ( $ ...
Sets the locale of the current User to the request if a User is logged in .
11,360
protected function addChild ( PropertyInterface $ property ) { if ( $ property instanceof SectionPropertyInterface ) { foreach ( $ property -> getChildProperties ( ) as $ childProperty ) { $ this -> addPropertyTags ( $ childProperty ) ; } } else { $ this -> addPropertyTags ( $ property ) ; } $ this -> properties [ $ pr...
adds a property to structure .
11,361
protected function addPropertyTags ( PropertyInterface $ property ) { foreach ( $ property -> getTags ( ) as $ tag ) { if ( ! array_key_exists ( $ tag -> getName ( ) , $ this -> tags ) ) { $ this -> tags [ $ tag -> getName ( ) ] = [ 'tag' => $ tag , 'properties' => [ $ tag -> getPriority ( ) => $ property ] , 'highest'...
add tags of properties .
11,362
public function getProperty ( $ name ) { $ result = $ this -> findProperty ( $ name ) ; if ( null !== $ result ) { return $ result ; } elseif ( isset ( $ this -> properties [ $ name ] ) ) { return $ this -> properties [ $ name ] ; } else { throw new NoSuchPropertyException ( $ name ) ; } }
returns a property instance with given name .
11,363
public function getPropertyByTagName ( $ tagName , $ highest = true ) { if ( array_key_exists ( $ tagName , $ this -> tags ) ) { return $ this -> tags [ $ tagName ] [ true === $ highest ? 'highest' : 'lowest' ] ; } else { throw new NoSuchPropertyException ( $ tagName ) ; } }
returns a property instance with given tag name .
11,364
public function getPropertiesByTagName ( $ tagName ) { if ( array_key_exists ( $ tagName , $ this -> tags ) ) { return $ this -> tags [ $ tagName ] [ 'properties' ] ; } else { throw new NoSuchPropertyException ( $ tagName ) ; } }
returns properties with given tag name sorted by priority .
11,365
private function findProperty ( $ name ) { foreach ( $ this -> getProperties ( true ) as $ property ) { if ( $ property -> getName ( ) === $ name ) { return $ property ; } } return ; }
find property in flatten properties .
11,366
public function getProperties ( $ flatten = false ) { if ( false === $ flatten ) { return $ this -> properties ; } else { $ result = [ ] ; foreach ( $ this -> properties as $ property ) { if ( $ property instanceof SectionPropertyInterface ) { $ result = array_merge ( $ result , $ property -> getChildProperties ( ) ) ;...
returns an array of properties .
11,367
public function __isset ( $ property ) { if ( null !== $ this -> findProperty ( $ property ) ) { return true ; } else { return isset ( $ this -> $ property ) ; } }
magic isset .
11,368
public function toArray ( $ complete = true ) { if ( $ complete ) { $ result = [ 'id' => $ this -> uuid , 'nodeType' => $ this -> nodeType , 'internal' => $ this -> internal , 'shadowLocales' => $ this -> getShadowLocales ( ) , 'contentLocales' => $ this -> getContentLocales ( ) , 'shadowOn' => $ this -> getIsShadow ( ...
returns an array of property value pairs .
11,369
public function getStructureTag ( $ name ) { if ( ! isset ( $ this -> structureTags [ $ name ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Trying to get undefined structure StructureTag "%s"' , $ name ) ) ; } return $ this -> structureTags [ $ name ] ; }
Return the tag with the given name .
11,370
protected function generateTemplates ( Webspace $ webspace ) { foreach ( $ this -> xpath -> query ( '/x:webspace/x:templates/x:template' ) as $ templateNode ) { $ template = $ templateNode -> nodeValue ; $ type = $ templateNode -> attributes -> getNamedItem ( 'type' ) -> nodeValue ; $ webspace -> addTemplate ( $ type ,...
Adds the template for the given types as described in the XML document .
11,371
public function sendEmailAction ( Request $ request , $ generateNewKey = true ) { try { $ user = $ this -> findUser ( $ request -> get ( 'user' ) ) ; if ( true === $ generateNewKey ) { $ this -> generateTokenForUser ( $ user ) ; } $ email = $ this -> getEmail ( $ user ) ; $ this -> sendTokenEmail ( $ user , $ this -> g...
Generates a token for a user and sends an email with a link to the resetting route .
11,372
public function resetAction ( Request $ request ) { try { $ token = $ request -> get ( 'token' ) ; $ user = $ this -> findUserByValidToken ( $ token ) ; $ this -> changePassword ( $ user , $ request -> get ( 'password' , '' ) ) ; $ this -> deleteToken ( $ user ) ; $ this -> loginUser ( $ user , $ request ) ; $ response...
Resets a users password .
11,373
protected function getSenderAddress ( Request $ request ) { $ sender = $ this -> getParameter ( 'sulu_security.reset_password.mail.sender' ) ; if ( ! $ sender || ! $ this -> isEmailValid ( $ sender ) ) { $ sender = 'no-reply@' . $ request -> getHost ( ) ; } return $ sender ; }
Returns the sender s email address .
11,374
private function getEmail ( UserInterface $ user ) { if ( null !== $ user -> getEmail ( ) ) { return $ user -> getEmail ( ) ; } return $ this -> container -> getParameter ( 'sulu_admin.email' ) ; }
Returns the users email or as a fallback the installation - email - adress .
11,375
private function findUserByValidToken ( $ token ) { try { $ user = $ this -> getUserRepository ( ) -> findUserByToken ( $ token ) ; if ( new \ DateTime ( ) > $ user -> getPasswordResetTokenExpiresAt ( ) ) { throw new InvalidTokenException ( $ token ) ; } return $ user ; } catch ( NoResultException $ exc ) { throw new I...
Returns a user for a given token and checks if the token is still valid .
11,376
private function loginUser ( UserInterface $ user , $ request ) { $ token = new UsernamePasswordToken ( $ user , null , 'admin' , $ user -> getRoles ( ) ) ; $ this -> get ( 'security.token_storage' ) -> setToken ( $ token ) ; $ event = new InteractiveLoginEvent ( $ request , $ token ) ; $ this -> get ( 'event_dispatche...
Gives a user a token so she s logged in .
11,377
private function deleteToken ( UserInterface $ user ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ user -> setPasswordResetToken ( null ) ; $ user -> setPasswordResetTokenExpiresAt ( null ) ; $ user -> setPasswordResetTokenEmailsSent ( null ) ; $ em -> persist ( $ user ) ; $ em -> flush ( ) ; }
Deletes the user s reset - password - token .
11,378
private function sendTokenEmail ( UserInterface $ user , $ from , $ to ) { if ( null === $ user -> getPasswordResetToken ( ) ) { throw new NoTokenFoundException ( $ user ) ; } $ maxNumberEmails = $ this -> getParameter ( 'sulu_security.reset_password.mail.token_send_limit' ) ; if ( $ user -> getPasswordResetTokenEmails...
Sends the password - reset - token of a user to an email - adress .
11,379
private function changePassword ( UserInterface $ user , $ password ) { if ( '' === $ password ) { throw new MissingPasswordException ( ) ; } $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ user -> setPassword ( $ this -> encodePassword ( $ user , $ password , $ user -> getSalt ( ) ) ) ; $ em -> persist ( $ user...
Changes the password of a user .
11,380
private function generateTokenForUser ( UserInterface $ user ) { if ( null !== $ user -> getPasswordResetToken ( ) && $ this -> dateIsInRequestFrame ( $ user -> getPasswordResetTokenExpiresAt ( ) ) ) { throw new TokenAlreadyRequestedException ( self :: getRequestInterval ( ) ) ; } $ em = $ this -> getDoctrine ( ) -> ge...
Generates a new token for a new user .
11,381
private function getUniqueToken ( $ startToken ) { try { $ this -> getUserRepository ( ) -> findUserByToken ( $ startToken ) ; } catch ( NoResultException $ ex ) { return $ startToken ; } return $ this -> getUniqueToken ( $ this -> getTokenGenerator ( ) -> generateToken ( ) ) ; }
If the passed token is unique returns it back otherwise returns a unique token .
11,382
private function encodePassword ( UserInterface $ user , $ password , $ salt ) { $ encoder = $ this -> get ( 'sulu_security.encoder_factory' ) -> getEncoder ( $ user ) ; return $ encoder -> encodePassword ( $ password , $ salt ) ; }
Returns an encoded password gor a given one .
11,383
private function hasSystem ( SuluUserInterface $ user ) { $ system = $ this -> getSystem ( ) ; foreach ( $ user -> getRoleObjects ( ) as $ role ) { if ( $ role -> getSystem ( ) === $ system ) { return true ; } } return false ; }
Check if given user has sulu - system .
11,384
private function isInsideImage ( ImageInterface $ image , $ x , $ y , $ width , $ height ) { if ( $ x < 0 || $ y < 0 ) { return false ; } if ( $ x + $ width > $ image -> getSize ( ) -> getWidth ( ) ) { return false ; } if ( $ y + $ height > $ image -> getSize ( ) -> getHeight ( ) ) { return false ; } return true ; }
Returns true iff the cropping does not exceed the image borders .
11,385
private function isNotSmallerThanFormat ( $ width , $ height , array $ format ) { if ( isset ( $ format [ 'scale' ] [ 'x' ] ) && $ width < $ format [ 'scale' ] [ 'x' ] ) { return false ; } if ( isset ( $ format [ 'scale' ] [ 'y' ] ) && $ height < $ format [ 'scale' ] [ 'y' ] ) { return false ; } return true ; }
Returns true iff the crop is greater or equal to the size of a given format .
11,386
public function setDefaultUser ( ConfigureOptionsEvent $ event ) { $ optionsResolver = $ event -> getOptions ( ) ; $ optionsResolver -> setDefault ( static :: USER_OPTION , null ) ; if ( null === $ this -> tokenStorage ) { return ; } $ token = $ this -> tokenStorage -> getToken ( ) ; if ( null === $ token || $ token in...
Sets the default user from the session .
11,387
public function addPhone ( \ Sulu \ Bundle \ ContactBundle \ Entity \ Phone $ phones ) { $ this -> phones [ ] = $ phones ; return $ this ; }
Add phones .
11,388
public function removePhone ( \ Sulu \ Bundle \ ContactBundle \ Entity \ Phone $ phones ) { $ this -> phones -> removeElement ( $ phones ) ; }
Remove phones .
11,389
public function getPortal ( $ key ) { return array_key_exists ( $ key , $ this -> portals ) ? $ this -> portals [ $ key ] : null ; }
Returns the portal with the given index .
11,390
public function getPortalInformations ( $ environment , $ types = null ) { if ( ! isset ( $ this -> portalInformations [ $ environment ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Unknown portal environment "%s"' , $ environment ) ) ; } if ( null === $ types ) { return $ this -> portalInformations [ $ envi...
Returns the portal informations for the given environment .
11,391
public function getWebspace ( $ key ) { return array_key_exists ( $ key , $ this -> webspaces ) ? $ this -> webspaces [ $ key ] : null ; }
Returns the webspace with the given key .
11,392
public function toArray ( ) { $ collection = [ ] ; $ webspaces = [ ] ; foreach ( $ this -> webspaces as $ webspace ) { $ webspaces [ ] = $ webspace -> toArray ( ) ; } $ portalInformations = [ ] ; foreach ( $ this -> portalInformations as $ environment => $ environmentPortalInformations ) { $ portalInformations [ $ envi...
Returns the content of these portals as array .
11,393
protected function retrieveIndexOfFieldDescriptor ( FieldDescriptorInterface $ fieldDescriptor , array $ fieldDescriptors ) { foreach ( $ fieldDescriptors as $ index => $ other ) { if ( $ fieldDescriptor -> compare ( $ other ) ) { return $ index ; } } return false ; }
Returns index of given FieldDescriptor in given array of descriptors . If no match is found false will be returned .
11,394
public function addTags ( ) : void { $ tags = $ this -> getTags ( ) ; $ currentStructureUuid = $ this -> getCurrentStructureUuid ( ) ; if ( $ currentStructureUuid && ! in_array ( $ currentStructureUuid , $ tags ) ) { $ tags [ ] = $ currentStructureUuid ; } if ( count ( $ tags ) <= 0 ) { return ; } $ this -> symfonyResp...
Adds tags from the reference store to the response tagger .
11,395
private function getTags ( ) : array { $ tags = [ ] ; foreach ( $ this -> referenceStorePool -> getStores ( ) as $ alias => $ referenceStore ) { $ tags = array_merge ( $ tags , $ this -> getTagsFromStore ( $ alias , $ referenceStore ) ) ; } return $ tags ; }
Merges tags from all registered stores .
11,396
private function getTagsFromStore ( $ alias , ReferenceStoreInterface $ referenceStore ) : array { $ tags = [ ] ; foreach ( $ referenceStore -> getAll ( ) as $ reference ) { $ tag = $ reference ; if ( ! Uuid :: isValid ( $ reference ) ) { $ tag = $ alias . '-' . $ reference ; } $ tags [ ] = $ tag ; } return $ tags ; }
Returns tags from given store .
11,397
private function getCurrentStructureUuid ( ) : ? string { $ request = $ this -> requestStack -> getCurrentRequest ( ) ; if ( ! $ request ) { return null ; } $ structure = $ request -> get ( 'structure' ) ; if ( ! $ structure || ! $ structure instanceof StructureInterface ) { return null ; } return $ structure -> getUui...
Returns uuid of current structure .
11,398
protected function findRoute ( $ uuid ) { $ document = $ this -> documentManager -> find ( $ uuid ) ; if ( ! $ document instanceof RouteDocument ) { return ; } return $ document ; }
Read route of custom - url identified by uuid .
11,399
private function bind ( CustomUrlDocument $ document , $ data ) { $ document -> setTitle ( $ data [ 'title' ] ) ; unset ( $ data [ 'title' ] ) ; $ metadata = $ this -> metadataFactory -> getMetadataForAlias ( 'custom_url' ) ; $ accessor = PropertyAccess :: createPropertyAccessor ( ) ; foreach ( $ metadata -> getFieldMa...
Bind data array to given document .