idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
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 -> hasSelectStatement ( $ queryBuilder , $ statement ) ) { $ queryBuilder -> addSelect ( $ this -> getSelectAs ( $ sortField , true ) ) ; } $ queryBuilder -> addOrderBy ( $ sortField -> getName ( ) , $ this -> sortOrders [ $ index ] ) ; } }
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 -> selectFields ) ; } return array_filter ( $ fields , function ( FieldDescriptorInterface $ fieldDescriptor ) { return $ fieldDescriptor instanceof DoctrineFieldDescriptorInterface ; } ) ; }
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 ( $ entityNames ) ; $ queryBuilder = $ this -> createQueryBuilder ( $ addJoins ) -> select ( $ select ) ; if ( $ this -> user && $ this -> permission && array_key_exists ( $ this -> permission , $ this -> permissions ) ) { $ this -> addAccessControl ( $ queryBuilder , $ this -> user , $ this -> permissions [ $ this -> permission ] , $ this -> securedEntityName , $ this -> encodeAlias ( $ this -> securedEntityName ) ) ; } return $ queryBuilder ; }
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 ( ) , $ necessaryEntityNames ) && $ field -> getEntityName ( ) !== $ this -> entityName ) { $ addJoins = array_merge ( $ addJoins , $ field -> getJoins ( ) ) ; } else { foreach ( $ field -> getJoins ( ) as $ entityName => $ join ) { if ( DoctrineJoinDescriptor :: JOIN_METHOD_INNER !== $ join -> getJoinMethod ( ) && false === array_search ( $ entityName , $ necessaryEntityNames ) ) { break ; } $ addJoins = array_merge ( $ addJoins , [ $ entityName => $ join ] ) ; } } } if ( $ this -> user && $ this -> permission && array_key_exists ( $ this -> permission , $ this -> permissions ) ) { foreach ( $ this -> permissionCheckFields as $ permissionCheckField ) { $ addJoins = array_merge ( $ addJoins , $ permissionCheckField -> getJoins ( ) ) ; } } return $ addJoins ; }
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 ; } } $ fieldEntityNames = [ ] ; foreach ( $ fields as $ key => $ field ) { if ( $ field instanceof DoctrineJoinDescriptor ) { $ fieldEntityNames [ ] = $ key ; } $ fieldEntityNames [ ] = $ field -> getEntityName ( ) ; } return array_unique ( $ fieldEntityNames ) ; }
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 ( $ this -> idField , ! empty ( $ this -> ids ) ? $ this -> ids : [ null ] ) ; } if ( null !== $ this -> excludedIds && ! empty ( $ this -> excludedIds ) ) { $ this -> notIn ( $ this -> idField , $ this -> excludedIds ) ; } if ( ! empty ( $ this -> expressions ) ) { foreach ( $ this -> expressions as $ expression ) { $ this -> queryBuilder -> andWhere ( '(' . $ expression -> getStatement ( $ this -> queryBuilder ) . ')' ) ; } } $ this -> assignGroupBy ( $ this -> queryBuilder ) ; if ( null !== $ this -> search ) { $ searchParts = [ ] ; foreach ( $ this -> searchFields as $ searchField ) { $ searchParts [ ] = $ searchField -> getSearch ( ) ; } $ this -> queryBuilder -> andWhere ( '(' . implode ( ' OR ' , $ searchParts ) . ')' ) ; $ this -> queryBuilder -> setParameter ( 'search' , '%' . str_replace ( '*' , '%' , $ this -> search ) . '%' ) ; } return $ this -> queryBuilder ; }
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 ( $ join -> getJoin ( ) ? : $ entity , $ this -> encodeAlias ( $ entity ) , $ join -> getJoinConditionMethod ( ) , $ join -> getJoinCondition ( ) ) ; break ; case DoctrineJoinDescriptor :: JOIN_METHOD_INNER : $ queryBuilder -> innerJoin ( $ join -> getJoin ( ) ? : $ entity , $ this -> encodeAlias ( $ entity ) , $ join -> getJoinConditionMethod ( ) , $ join -> getJoinCondition ( ) ) ; break ; } } }
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 -> fieldDescriptors [ $ uniqueName ] ; } $ this -> expressionFields = $ descriptors ; return $ descriptors ; } return $ this -> expressionFields ; }
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 BasicExpressionInterface ) { $ fieldNames [ ] = $ expression -> getFieldName ( ) ; } } return $ fieldNames ; }
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 = $ this -> getFieldDescriptors ( ) ; $ restHelper -> initializeListBuilder ( $ listBuilder , $ fieldDescriptors ) ; $ fieldsParam = $ request -> get ( 'fields' ) ; $ fields = explode ( ',' , $ fieldsParam ) ; if ( null === $ fieldsParam || false !== array_search ( 'webspaceKeys' , $ fields ) ) { $ listBuilder -> addGroupBy ( $ fieldDescriptors [ 'id' ] ) ; } $ results = $ listBuilder -> execute ( ) ; $ list = new ListRepresentation ( $ results , 'target-groups' , 'get_target-groups' , $ request -> query -> all ( ) , $ listBuilder -> getCurrentPage ( ) , $ listBuilder -> getLimit ( ) , $ listBuilder -> count ( ) ) ; return $ this -> handleView ( $ this -> view ( $ list , 200 ) ) ; }
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 ) ; $ this -> getEntityManager ( ) -> flush ( ) ; return $ this -> handleView ( $ this -> view ( $ 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 ) ; foreach ( $ targetGroups as $ targetGroup ) { $ this -> getEntityManager ( ) -> remove ( $ targetGroup ) ; } $ this -> getEntityManager ( ) -> flush ( ) ; return $ this -> handleView ( $ this -> view ( null , 204 ) ) ; }
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 $ cleanedFileName ; }
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 ( ! $ metadata -> hasField ( self :: CREATED_FIELD ) ) { $ metadata -> mapField ( [ 'fieldName' => self :: CREATED_FIELD , 'type' => 'datetime' , 'notnull' => true , ] ) ; } if ( ! $ metadata -> hasField ( self :: CHANGED_FIELD ) ) { $ metadata -> mapField ( [ 'fieldName' => self :: CHANGED_FIELD , 'type' => 'datetime' , 'notnull' => true , ] ) ; } } }
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 :: CREATED_FIELD ) ; if ( null === $ created ) { $ meta -> setFieldValue ( $ entity , self :: CREATED_FIELD , new \ DateTime ( ) ) ; } $ meta -> setFieldValue ( $ entity , self :: CHANGED_FIELD , new \ DateTime ( ) ) ; }
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_array ( $ localization -> getLocale ( ) , $ locales ) ) { $ locales [ ] = $ localization -> getLocale ( ) ; $ localizations [ ] = [ 'localization' => $ localization -> getLocale ( ) , 'name' => $ localization -> getLocale ( Localization :: DASH ) , 'id' => $ i ++ , ] ; } } } $ data = [ '_embedded' => $ localizations , 'total' => count ( $ localizations ) , ] ; return new JsonResponse ( $ data ) ; }
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 ( $ document , $ setter ) ) { continue ; } $ value = $ this -> getParser ( $ format ) -> getPropertyData ( $ key , $ data ) ; $ document -> $ setter ( $ this -> getSetterValue ( $ key , $ value ) ) ; } }
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_decode ( $ value ) ; break ; } return $ value ; }
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 ) -> getPropertyData ( $ propertyName , $ data , null , $ extensionKey ) ; $ extensionData [ $ propertyName ] = $ value ; } $ extension -> import ( $ node , $ extensionData , $ webspaceKey , $ locale , $ format ) ; }
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 ( ) ) ; } $ title = trim ( implode ( ' ' , $ rlpParts ) ) ; return $ this -> rlpStrategy -> generate ( $ title , $ parentUuid , $ webspaceKey , $ locale ) ; }
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' === $ value ) { $ value = filter_var ( $ value , FILTER_VALIDATE_BOOLEAN ) ; } $ attributes [ $ matches [ 'name' ] [ $ i ] ] = $ value ; } return $ attributes ; }
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 , $ gitignore ) ; }
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 ( ) ; $ propertyName = $ this -> getPropertyName ( self :: SHADOW_ON_PROPERTY , $ locale ) ; $ this -> upgradeNode ( $ node , $ propertyName , $ locale ) ; } }
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 -> getPropertyValue ( $ this -> getPropertyName ( self :: SHADOW_BASE_PROPERTY , $ locale ) ) ; $ tags = $ this -> getTags ( $ node , $ shadowLocale ) ; $ categories = $ this -> getCategories ( $ node , $ shadowLocale ) ; $ navigationContext = $ this -> getNavigationContext ( $ node , $ shadowLocale ) ; $ node -> setProperty ( sprintf ( self :: TAGS_PROPERTY , $ locale ) , $ tags ) ; $ node -> setProperty ( sprintf ( self :: CATEGORIES_PROPERTY , $ locale ) , $ categories ) ; $ node -> setProperty ( sprintf ( self :: NAVIGATION_CONTEXT_PROPERTY , $ locale ) , $ navigationContext ) ; }
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 -> urlGenerator -> generate ( 'sulu_admin.metadata' , [ 'type' => ':type' , 'key' => ':key' ] ) , ] , 'fieldTypeOptions' => $ this -> fieldTypeOptionRegistry -> toArray ( ) , 'internalLinkTypes' => $ this -> linkProviderPool -> getConfiguration ( ) , 'navigation' => $ this -> navigationRegistry -> getNavigation ( ) -> getChildrenAsArray ( ) , 'routes' => $ this -> routeRegistry -> getRoutes ( ) , 'resources' => $ this -> resources , 'smartContent' => array_map ( function ( DataProviderInterface $ dataProvider ) { return $ dataProvider -> getConfiguration ( ) ; } , $ this -> dataProviderPool -> getAll ( ) ) , 'user' => $ user , 'contact' => $ contact , ] , 'sulu_contact' => [ 'addressTypes' => $ this -> managerRegistry -> getRepository ( 'SuluContactBundle:AddressType' ) -> findAll ( ) , 'countries' => $ this -> managerRegistry -> getRepository ( 'SuluContactBundle:Country' ) -> findAll ( ) , ] , 'sulu_media' => [ 'endpoints' => [ 'image_format' => $ this -> urlGenerator -> generate ( 'sulu_media.redirect' , [ 'id' => ':id' ] ) , ] , ] , 'sulu_preview' => [ 'endpoints' => [ 'start' => $ this -> urlGenerator -> generate ( 'sulu_preview.start' ) , 'render' => $ this -> urlGenerator -> generate ( 'sulu_preview.render' ) , 'update' => $ this -> urlGenerator -> generate ( 'sulu_preview.update' ) , 'update-context' => $ this -> urlGenerator -> generate ( 'sulu_preview.update-context' ) , 'stop' => $ this -> urlGenerator -> generate ( 'sulu_preview.stop' ) , ] , 'debounceDelay' => $ this -> previewDelay , 'mode' => $ this -> previewMode , ] , 'sulu_security' => [ 'endpoints' => [ 'contexts' => $ this -> urlGenerator -> generate ( 'cget_contexts' ) , ] , ] , 'sulu_website' => [ 'endpoints' => [ 'clearCache' => $ this -> urlGenerator -> generate ( 'sulu_website.cache.remove' ) , ] , ] , ] ) ; $ context = new Context ( ) ; $ context -> setGroups ( [ 'frontend' , 'partialContact' , 'fullRoute' ] ) ; $ view -> setContext ( $ context ) ; $ view -> setFormat ( 'json' ) ; return $ this -> viewHandler -> handle ( $ view ) ; }
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 ( $ portal , $ environment , $ segments , [ ] , $ urlAddress , $ portal -> getLocalization ( $ locale ) , $ url ) ; } else { foreach ( $ portal -> getLocalizations ( ) as $ localization ) { $ language = $ url -> getLanguage ( ) ? $ url -> getLanguage ( ) : $ localization -> getLanguage ( ) ; $ country = $ url -> getCountry ( ) ? $ url -> getCountry ( ) : $ localization -> getCountry ( ) ; $ replacers = [ ReplacerInterface :: REPLACER_LANGUAGE => $ language , ReplacerInterface :: REPLACER_COUNTRY => $ country , ReplacerInterface :: REPLACER_LOCALIZATION => $ localization -> getLocale ( Localization :: DASH ) , ] ; $ this -> buildUrlFullMatch ( $ portal , $ environment , $ segments , $ replacers , $ urlAddress , $ localization , $ url ) ; } $ this -> buildUrlPartialMatch ( $ portal , $ environment , $ urlAddress , $ url ) ; } }
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 , true ) ) ) ; } $ medias = $ this -> mediaManager -> get ( $ locale , [ 'ids' => $ data [ 'ids' ] , ] ) ; } if ( ! $ medias ) { return ; } $ media = current ( $ medias ) ; if ( ! $ media ) { return ; } $ formats = $ media -> getThumbnails ( ) ; if ( ! isset ( $ formats [ $ this -> searchImageFormat ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Search image format "%s" is not known' , $ this -> searchImageFormat ) ) ; } return $ formats [ $ this -> searchImageFormat ] ; }
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 , $ structure ) ; $ structureBridge -> setDocument ( $ document ) ; return $ structureBridge ; }
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 === $ format ) { return $ this -> redirect ( $ media -> getUrl ( ) ) ; } if ( ! array_key_exists ( $ format , $ media -> getFormats ( ) ) ) { throw $ this -> createNotFoundException ( ) ; } return $ this -> redirect ( $ media -> getFormats ( ) [ $ format ] ) ; }
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 ) ) , PermissionTypes :: EDIT ) ; $ default = $ request -> get ( 'defaultUuid' ) ; $ areas = $ this -> getLocalizedAreas ( ) ; $ area = $ areas [ $ key ] ; $ defaultSnippet = $ this -> get ( 'sulu_snippet.default_snippet.manager' ) -> save ( $ webspaceKey , $ key , $ default , $ this -> getUser ( ) -> getLocale ( ) ) ; return new JsonResponse ( [ 'key' => $ key , 'template' => $ area [ 'template' ] , 'title' => $ area [ 'title' ] , 'defaultUuid' => $ defaultSnippet ? $ defaultSnippet -> getUuid ( ) : null , 'defaultTitle' => $ defaultSnippet ? $ defaultSnippet -> getTitle ( ) : null , 'valid' => true , ] ) ; }
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 ) ) , PermissionTypes :: EDIT ) ; $ areas = $ this -> getLocalizedAreas ( ) ; $ area = $ areas [ $ key ] ; $ this -> get ( 'sulu_snippet.default_snippet.manager' ) -> remove ( $ webspaceKey , $ key ) ; return new JsonResponse ( [ 'key' => $ key , 'template' => $ area [ 'template' ] , 'title' => $ area [ 'title' ] , 'defaultUuid' => null , 'defaultTitle' => null , 'valid' => true , ] ) ; }
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 , $ userRoleData ) { return $ this -> updateUserRole ( $ userRole , $ userRoleData ) ; } ; $ add = function ( $ userRole ) use ( $ user ) { return $ this -> addUserRole ( $ user , $ userRole ) ; } ; $ entities = $ user -> getUserRoles ( ) ; $ result = $ this -> processSubEntities ( $ entities , $ userRoles , $ get , $ add , $ update , $ delete ) ; $ this -> resetIndexOfSubentites ( $ entities ) ; return $ result ; }
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 ( $ userGroup , $ userGroupData ) { return $ this -> updateUserGroup ( $ userGroup , $ userGroupData ) ; } ; $ add = function ( $ userGroup ) use ( $ user ) { return $ this -> addUserGroup ( $ user , $ userGroup ) ; } ; $ entities = $ user -> getUserGroups ( ) ; $ result = $ this -> processSubEntities ( $ entities , $ userGroups , $ get , $ add , $ update , $ delete ) ; $ this -> resetIndexOfSubentites ( $ entities ) ; return $ result ; }
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 -> setRole ( $ role ) ; if ( array_key_exists ( 'locales' , $ userRoleData ) ) { $ userRole -> setLocale ( json_encode ( $ userRoleData [ 'locales' ] ) ) ; } else { $ userRole -> setLocale ( $ userRoleData [ 'locale' ] ) ; } return true ; }
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' ] [ 'id' ] ) ; } if ( $ user -> getUserRoles ( ) ) { foreach ( $ user -> getUserRoles ( ) as $ containedRole ) { if ( $ containedRole -> getRole ( ) -> getId ( ) === $ role -> getId ( ) ) { $ alreadyContains = true ; } } } if ( false === $ alreadyContains ) { $ userRole = new UserRole ( ) ; $ userRole -> setUser ( $ user ) ; $ userRole -> setRole ( $ role ) ; $ userRole -> setLocale ( json_encode ( $ userRoleData [ 'locales' ] ) ) ; $ this -> em -> persist ( $ userRole ) ; $ user -> addUserRole ( $ userRole ) ; } return true ; }
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' ] ) ; } $ userGroup = new UserGroup ( ) ; $ userGroup -> setUser ( $ user ) ; $ userGroup -> setGroup ( $ group ) ; $ userGroup -> setLocale ( json_encode ( $ userGroupData [ 'locales' ] ) ) ; $ this -> em -> persist ( $ userGroup ) ; $ user -> addUserGroup ( $ userGroup ) ; return true ; }
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' ] ) ; } $ userGroup -> setGroup ( $ group ) ; if ( array_key_exists ( 'locales' , $ userGroupData ) ) { $ userGroup -> setLocale ( json_encode ( $ userGroupData [ 'locales' ] ) ) ; } else { $ userGroup -> setLocale ( $ userGroupData [ 'locale' ] ) ; } return true ; }
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' ] [ 0 ] [ 'email' ] ; } if ( null !== $ email ) { if ( ! $ this -> isEmailUnique ( $ email ) ) { throw new EmailNotUniqueException ( $ email ) ; } $ user -> setEmail ( $ email ) ; } } else { if ( null !== $ email ) { if ( $ email !== $ user -> getEmail ( ) && ! $ this -> isEmailUnique ( $ email ) ) { throw new EmailNotUniqueException ( $ email ) ; } $ user -> setEmail ( $ email ) ; } else { $ user -> setEmail ( null ) ; } } }
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 ( $ locale ) ; $ this -> translator -> setLocale ( $ locale ) ; }
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 [ $ property -> getName ( ) ] = $ property ; }
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' => $ property , 'lowest' => $ property , ] ; } else { $ this -> tags [ $ tag -> getName ( ) ] [ 'properties' ] [ $ tag -> getPriority ( ) ] = $ property ; $ highestProperty = $ this -> tags [ $ tag -> getName ( ) ] [ 'highest' ] ; if ( $ highestProperty -> getTag ( $ tag -> getName ( ) ) -> getPriority ( ) < $ tag -> getPriority ( ) ) { $ this -> tags [ $ tag -> getName ( ) ] [ 'highest' ] = $ property ; } $ lowestProperty = $ this -> tags [ $ tag -> getName ( ) ] [ 'lowest' ] ; if ( $ lowestProperty -> getTag ( $ tag -> getName ( ) ) -> getPriority ( ) > $ tag -> getPriority ( ) ) { $ this -> tags [ $ tag -> getName ( ) ] [ 'lowest' ] = $ property ; } } } }
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 ( ) ) ; } else { $ result [ ] = $ property ; } } return $ result ; } }
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 ( ) , 'shadowBaseLanguage' => $ this -> getShadowBaseLanguage ( ) ? : false , 'template' => $ this -> getKey ( ) , 'hasSub' => $ this -> hasChildren , 'creator' => $ this -> creator , 'changer' => $ this -> changer , 'created' => $ this -> created , 'changed' => $ this -> changed , ] ; if ( null !== $ this -> type ) { $ result [ 'type' ] = $ this -> getType ( ) -> toArray ( ) ; } if ( self :: NODE_TYPE_INTERNAL_LINK === $ this -> nodeType ) { $ result [ 'linked' ] = 'internal' ; } elseif ( self :: NODE_TYPE_EXTERNAL_LINK === $ this -> nodeType ) { $ result [ 'linked' ] = 'external' ; } $ this -> appendProperties ( $ this -> getProperties ( ) , $ result ) ; return $ result ; } else { $ result = [ 'id' => $ this -> uuid , 'path' => $ this -> path , 'nodeType' => $ this -> nodeType , 'internal' => $ this -> internal , 'getContentLocales' => $ this -> getContentLocales ( ) , 'hasSub' => $ this -> hasChildren , 'title' => $ this -> getProperty ( 'title' ) -> toArray ( ) , ] ; if ( null !== $ this -> type ) { $ result [ 'type' ] = $ this -> getType ( ) -> toArray ( ) ; } if ( self :: NODE_TYPE_INTERNAL_LINK === $ this -> nodeType ) { $ result [ 'linked' ] = 'internal' ; } elseif ( self :: NODE_TYPE_EXTERNAL_LINK === $ this -> nodeType ) { $ result [ 'linked' ] = 'external' ; } return $ result ; } }
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 , $ template ) ; } return $ webspace ; }
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 -> getSenderAddress ( $ request ) , $ email ) ; $ response = new JsonResponse ( [ 'email' => $ email ] ) ; } catch ( EntityNotFoundException $ ex ) { $ response = new JsonResponse ( $ ex -> toArray ( ) , 400 ) ; } catch ( TokenAlreadyRequestedException $ ex ) { $ response = new JsonResponse ( $ ex -> toArray ( ) , 400 ) ; } catch ( NoTokenFoundException $ ex ) { $ response = new JsonResponse ( $ ex -> toArray ( ) , 400 ) ; } catch ( TokenEmailsLimitReachedException $ ex ) { $ response = new JsonResponse ( $ ex -> toArray ( ) , 400 ) ; } catch ( EmailTemplateException $ ex ) { $ response = new JsonResponse ( $ ex -> toArray ( ) , 400 ) ; } catch ( UserNotInSystemException $ ex ) { $ response = new JsonResponse ( $ ex -> toArray ( ) , 400 ) ; } return $ response ; }
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 = new JsonResponse ( [ 'url' => $ this -> get ( 'router' ) -> generate ( 'sulu_admin' ) ] ) ; } catch ( InvalidTokenException $ ex ) { $ response = new JsonResponse ( $ ex -> toArray ( ) , 400 ) ; } catch ( MissingPasswordException $ ex ) { $ response = new JsonResponse ( $ ex -> toArray ( ) , 400 ) ; } return $ 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 InvalidTokenException ( $ token ) ; } }
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_dispatcher' ) -> dispatch ( 'security.interactive_login' , $ event ) ; }
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 -> getPasswordResetTokenEmailsSent ( ) === $ maxNumberEmails ) { throw new TokenEmailsLimitReachedException ( $ maxNumberEmails , $ user ) ; } $ mailer = $ this -> get ( 'mailer' ) ; $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ message = $ mailer -> createMessage ( ) -> setSubject ( $ this -> getSubject ( ) ) -> setFrom ( $ from ) -> setTo ( $ to ) -> setBody ( $ this -> getMessage ( $ user ) ) ; $ mailer -> send ( $ message ) ; $ user -> setPasswordResetTokenEmailsSent ( $ user -> getPasswordResetTokenEmailsSent ( ) + 1 ) ; $ em -> persist ( $ user ) ; $ em -> flush ( ) ; }
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 ) ; $ em -> flush ( ) ; }
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 ( ) -> getManager ( ) ; $ user -> setPasswordResetToken ( $ this -> getToken ( ) ) ; $ expireDateTime = ( new \ DateTime ( ) ) -> add ( self :: getResetInterval ( ) ) ; $ user -> setPasswordResetTokenExpiresAt ( $ expireDateTime ) ; $ user -> setPasswordResetTokenEmailsSent ( 0 ) ; $ em -> persist ( $ user ) ; $ em -> flush ( ) ; }
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 instanceof AnonymousToken ) { return ; } $ user = $ token -> getUser ( ) ; if ( ! $ user instanceof UserInterface ) { return ; } $ optionsResolver -> setDefault ( static :: USER_OPTION , $ user -> getId ( ) ) ; }
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 [ $ environment ] ; } return array_filter ( $ this -> portalInformations [ $ environment ] , function ( PortalInformation $ portalInformation ) use ( $ types ) { return in_array ( $ portalInformation -> getType ( ) , $ types ) ; } ) ; }
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 [ $ environment ] = [ ] ; foreach ( $ environmentPortalInformations as $ environmentPortalInformation ) { $ portalInformations [ $ environment ] [ $ environmentPortalInformation -> getUrl ( ) ] = $ environmentPortalInformation -> toArray ( ) ; } } $ collection [ 'webspaces' ] = $ webspaces ; $ collection [ 'portalInformations' ] = $ portalInformations ; return $ collection ; }
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 -> symfonyResponseTagger -> addTags ( $ tags ) ; }
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 -> getUuid ( ) ; }
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 -> getFieldMappings ( ) as $ fieldName => $ mapping ) { if ( ! array_key_exists ( $ fieldName , $ data ) ) { continue ; } $ value = $ data [ $ fieldName ] ; if ( array_key_exists ( 'type' , $ mapping ) && 'reference' === $ mapping [ 'type' ] ) { $ value = $ this -> documentManager -> find ( $ value , LOCALE , [ 'load_ghost_content' => true ] ) ; } $ accessor -> setValue ( $ document , $ fieldName , $ value ) ; } }
Bind data array to given document .