idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
14,200 | private function createSignatureHash ( Signature $ signature ) { $ length = $ this -> getSignatureLength ( ) ; return pack ( 'H*' , sprintf ( '%s%s' , str_pad ( $ this -> adapter -> decHex ( $ signature -> getR ( ) ) , $ length , '0' , STR_PAD_LEFT ) , str_pad ( $ this -> adapter -> decHex ( $ signature -> getS ( ) ) , $ length , '0' , STR_PAD_LEFT ) ) ) ; } | Creates a binary signature with R and S coordinates |
14,201 | private function extractSignature ( $ value ) { $ length = $ this -> getSignatureLength ( ) ; $ value = unpack ( 'H*' , $ value ) [ 1 ] ; return new Signature ( $ this -> adapter -> hexDec ( substr ( $ value , 0 , $ length ) ) , $ this -> adapter -> hexDec ( substr ( $ value , $ length ) ) ) ; } | Extracts R and S values from given data |
14,202 | private function getKeyContent ( Key $ key , $ header ) { $ match = null ; preg_match ( '/^[\-]{5}BEGIN ' . $ header . '[\-]{5}(.*)[\-]{5}END ' . $ header . '[\-]{5}$/' , str_replace ( [ PHP_EOL , "\n" , "\r" ] , '' , $ key -> getContent ( ) ) , $ match ) ; if ( isset ( $ match [ 1 ] ) ) { return $ match [ 1 ] ; } throw new \ InvalidArgumentException ( 'This is not a valid ECDSA key.' ) ; } | Extracts the base 64 value from the PEM certificate |
14,203 | public function sourceUrl ( $ media ) { return new \ Twig_Markup ( $ this -> pool -> getProvider ( $ media -> getProvider ( ) ) -> getUrl ( $ media ) , 'utf8' ) ; } | Gets the source url of a media item |
14,204 | public function getSearchResults ( ) { $ term = $ this -> getRequest ( ) -> get ( 'search' , null ) ; if ( ! $ term ) { return [ ] ; } $ host = $ this -> getRequest ( ) -> getHost ( ) ; $ locale = $ this -> getRequest ( ) -> attributes -> get ( 'content' ) -> getLocale ( ) ; return $ this -> contentManager -> getRepository ( ) -> search ( $ term , $ host , $ locale ) ; } | Get the search results |
14,205 | public function index ( ) { Session :: forget ( 'install-module' ) ; $ result = [ ] ; foreach ( $ this -> extensions as $ ext ) { if ( extension_loaded ( $ ext ) ) { $ result [ $ ext ] = 'true' ; } else { $ result [ $ ext ] = false ; } } return view ( 'avored-install::install.extension' ) -> with ( 'result' , $ result ) ; } | Display all needed PHP Extension for the AvoRed E commerce App |
14,206 | public function build ( ContainerBuilder $ container ) { parent :: build ( $ container ) ; $ container -> addCompilerPass ( new ConfigurationCompilerPass ( ) ) ; $ container -> addCompilerPass ( new VendorCompilerPass ( ) ) ; } | Registers the compiler passes |
14,207 | public function flattenRoles ( $ data ) { $ result = array ( ) ; foreach ( $ data as $ key => $ value ) { if ( substr ( $ key , 0 , 4 ) === 'ROLE' ) { $ result [ $ key ] = $ key ; } if ( is_array ( $ value ) ) { $ tmpresult = $ this -> flattenRoles ( $ value ) ; if ( count ( $ tmpresult ) > 0 ) { $ result = array_merge ( $ result , $ tmpresult ) ; } } else { $ result [ $ value ] = $ value ; } } return array_unique ( $ result ) ; } | Flatten roles . |
14,208 | private function addBlocksSection ( ArrayNodeDefinition $ node ) { $ node -> children ( ) -> arrayNode ( 'blocks' ) -> addDefaultsIfNotSet ( ) -> children ( ) -> arrayNode ( 'subscribe' ) -> addDefaultsIfNotSet ( ) -> children ( ) -> scalarNode ( 'view' ) -> defaultValue ( 'OpiferMailingListBundle:Block:subscribe.html.twig' ) -> end ( ) -> arrayNode ( 'templates' ) -> prototype ( 'scalar' ) -> end ( ) -> normalizeKeys ( false ) -> useAttributeAsKey ( 'name' ) -> defaultValue ( [ ] ) -> end ( ) -> end ( ) -> end ( ) -> end ( ) -> end ( ) -> end ( ) ; } | Add Block specific configuration . |
14,209 | public function createAction ( Request $ request ) { $ mailingList = new MailingList ( ) ; $ form = $ this -> createForm ( MailingListType :: class , $ mailingList , [ 'action' => $ this -> generateUrl ( 'opifer_mailing_list_mailing_list_create' ) , ] ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ mailingList ) ; $ em -> flush ( ) ; return $ this -> redirectToRoute ( 'opifer_mailing_list_mailing_list_index' ) ; } return $ this -> render ( 'OpiferMailingListBundle:MailingList:create.html.twig' , [ 'form' => $ form -> createView ( ) , ] ) ; } | Add new Mailing List . |
14,210 | public function editAction ( Request $ request , $ id ) { $ mailingList = $ this -> getDoctrine ( ) -> getRepository ( 'OpiferMailingListBundle:MailingList' ) -> find ( $ id ) ; $ form = $ this -> createForm ( MailingListType :: class , $ mailingList ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> flush ( ) ; return $ this -> redirectToRoute ( 'opifer_mailing_list_mailing_list_index' ) ; } return $ this -> render ( 'OpiferMailingListBundle:MailingList:edit.html.twig' , [ 'form' => $ form -> createView ( ) , 'mailing_list' => $ mailingList , ] ) ; } | Edit Mailing List . |
14,211 | public function deleteAction ( $ id ) { $ mailingList = $ this -> getDoctrine ( ) -> getRepository ( 'OpiferMailingListBundle:MailingList' ) -> find ( $ id ) ; if ( ! empty ( $ mailingList ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> remove ( $ mailingList ) ; $ em -> flush ( ) ; } return $ this -> redirectToRoute ( 'opifer_mailing_list_mailing_list_index' ) ; } | Delete Mailing List . |
14,212 | public function idsAction ( $ ids ) { $ items = $ this -> get ( 'opifer.content.content_manager' ) -> getRepository ( ) -> findOrderedByIds ( $ ids ) ; $ stringHelper = $ this -> container -> get ( 'opifer.content.string_helper' ) ; $ contents = $ this -> get ( 'jms_serializer' ) -> serialize ( $ items , 'json' , SerializationContext :: create ( ) -> setGroups ( [ 'list' ] ) -> enableMaxDepthChecks ( ) ) ; $ contents = $ stringHelper -> replaceLinks ( $ contents ) ; $ data = [ 'results' => json_decode ( $ contents , true ) , 'total_results' => count ( $ items ) , ] ; return new JsonResponse ( $ data ) ; } | Get a content items by a list of ids . |
14,213 | public function viewAction ( Request $ request , $ id , $ structure = 'tree' ) { $ response = new JsonResponse ( ) ; $ contentRepository = $ this -> get ( 'opifer.content.content_manager' ) -> getRepository ( ) ; $ content = $ contentRepository -> findOneByIdOrSlug ( $ id , true ) ; if ( $ content -> getSlug ( ) === '404' ) { $ response -> setStatusCode ( 404 ) ; } $ version = $ request -> query -> get ( '_version' ) ; $ debug = $ this -> getParameter ( 'kernel.debug' ) ; $ response -> setLastModified ( $ content -> getLastUpdateDate ( ) ) ; $ response -> setPublic ( ) ; if ( null === $ version && false == $ debug && $ response -> isNotModified ( $ request ) ) { return $ response ; } $ environment = $ this -> get ( 'opifer.content.block_environment' ) ; $ environment -> setObject ( $ content ) ; if ( null !== $ version && $ this -> isGranted ( 'ROLE_ADMIN' ) ) { $ environment -> setDraft ( true ) ; } $ environment -> load ( ) ; $ context = SerializationContext :: create ( ) -> addExclusionStrategy ( new BlockExclusionStrategy ( $ content ) ) ; if ( $ structure == 'tree' ) { $ blocks = $ environment -> getRootBlocks ( ) ; $ context -> setGroups ( [ 'Default' , 'tree' , 'detail' ] ) ; } else { $ blocks = $ environment -> getBlocks ( ) ; $ context -> setGroups ( [ 'Default' , 'detail' ] ) -> enableMaxDepthChecks ( ) ; } $ contentItem = [ 'id' => $ content -> getId ( ) , 'created_at' => $ content -> getCreatedAt ( ) , 'updated_at' => $ content -> getUpdatedAt ( ) , 'published_at' => $ content -> getPublishAt ( ) , 'title' => $ content -> getTitle ( ) , 'shortTitle' => $ content -> getShortTitle ( ) , 'description' => $ content -> getDescription ( ) , 'slug' => $ content -> getSlug ( ) , 'alias' => $ content -> getAlias ( ) , 'blocks' => $ blocks , 'attributes' => $ content -> getPivotedAttributes ( ) , 'medias' => $ content -> getMedias ( ) , ] ; $ stringHelper = $ this -> container -> get ( 'opifer.content.string_helper' ) ; $ json = $ this -> get ( 'jms_serializer' ) -> serialize ( $ contentItem , 'json' , $ context ) ; $ json = $ stringHelper -> replaceLinks ( $ json ) ; $ response -> setData ( json_decode ( $ json , true ) ) ; return $ response ; } | Get a single content item . |
14,214 | public function deleteAction ( $ id ) { $ manager = $ this -> get ( 'opifer.content.content_manager' ) ; $ content = $ manager -> getRepository ( ) -> find ( $ id ) ; $ hashedSlug = $ content -> getSlug ( ) . '-' . sha1 ( date ( 'Y-m-d H:i:s' ) ) ; $ content -> setSlug ( $ hashedSlug ) ; $ manager -> save ( $ content ) ; $ manager -> remove ( $ content ) ; return new JsonResponse ( [ 'success' => true ] ) ; } | Delete content . |
14,215 | public function setCurrentTime ( $ currentTime ) { $ this -> items [ 'iat' ] = ( int ) $ currentTime ; $ this -> items [ 'nbf' ] = ( int ) $ currentTime ; $ this -> items [ 'exp' ] = ( int ) $ currentTime ; } | Configures the time that iat nbf and exp should be based on |
14,216 | public function get ( $ name ) { return isset ( $ this -> items [ $ name ] ) ? $ this -> items [ $ name ] : null ; } | Returns the requested item |
14,217 | public function createAction ( Request $ request ) { $ this -> denyAccessUnlessGranted ( 'ROLE_ADMIN' ) ; $ locale = new Locale ( ) ; $ form = $ this -> createForm ( new LocaleType ( ) , $ locale ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ locale ) ; $ em -> flush ( ) ; $ this -> addFlash ( 'success' , 'Locale has been created successfully' ) ; return $ this -> redirectToRoute ( 'opifer_cms_locale_edit' , [ 'id' => $ locale -> getId ( ) ] ) ; } return $ this -> render ( 'OpiferCmsBundle:Backend/Locale:create.html.twig' , [ 'locale' => $ locale , 'form' => $ form -> createView ( ) ] ) ; } | Create a locale |
14,218 | public function editAction ( Request $ request , $ id = null ) { $ this -> denyAccessUnlessGranted ( 'ROLE_ADMIN' ) ; $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; if ( is_numeric ( $ id ) ) { $ locale = $ em -> getRepository ( Locale :: class ) -> find ( $ id ) ; } else { $ locale = $ em -> getRepository ( Locale :: class ) -> findOneByLocale ( $ id ) ; } $ form = $ this -> createForm ( new LocaleType ( ) , $ locale ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ em -> persist ( $ locale ) ; $ em -> flush ( ) ; $ this -> addFlash ( 'success' , 'Locale has been updated successfully' ) ; return $ this -> redirectToRoute ( 'opifer_cms_locale_edit' , [ 'id' => $ locale -> getId ( ) ] ) ; } return $ this -> render ( 'OpiferCmsBundle:Backend/Locale:edit.html.twig' , [ 'locale' => $ locale , 'form' => $ form -> createView ( ) ] ) ; } | Edit a Locale |
14,219 | public function getOrdered ( ) { if ( ! $ this -> sort ) { return $ this -> content ; } $ unordered = [ ] ; foreach ( $ this -> content as $ content ) { $ unordered [ $ content -> getId ( ) ] = $ content ; } $ ordered = [ ] ; $ sort = json_decode ( $ this -> sort , true ) ; $ order = $ sort [ 'order' ] ; foreach ( $ order as $ id ) { if ( isset ( $ unordered [ $ id ] ) ) { $ ordered [ ] = $ unordered [ $ id ] ; } } return $ ordered ; } | Get content items ordered by the sort property |
14,220 | public function prepend ( ContainerBuilder $ container ) { $ configs = $ container -> getExtensionConfig ( $ this -> getAlias ( ) ) ; $ config = $ this -> processConfiguration ( new Configuration ( ) , $ configs ) ; $ container -> setAlias ( 'opifer.content.content_manager' , $ config [ 'content_manager' ] ) ; $ container -> setDefinition ( 'opifer.content.cache_provider' , new Definition ( $ config [ 'cache_provider' ] ) ) ; $ parameters = $ this -> getParameters ( $ config ) ; foreach ( $ parameters as $ key => $ value ) { $ container -> setParameter ( $ key , $ value ) ; } $ this -> prependExtensionConfig ( $ container , $ config ) ; } | Prepend our config before other bundles so we can preset their config with our parameters . |
14,221 | public function transform ( $ value ) { if ( null === $ value || ! ( $ value instanceof Collection ) ) { return '' ; } $ string = '' ; foreach ( $ value as $ item ) { $ string .= $ item -> getId ( ) ; if ( $ value -> last ( ) != $ item ) { $ string .= ',' ; } } return $ string ; } | Transforms an ArrayCollection Object to a single Object . |
14,222 | public function shouldSkipClass ( ClassMetadata $ metadata , Context $ context ) { $ obj = null ; foreach ( $ context -> getVisitingSet ( ) as $ item ) { $ obj = $ item ; } if ( $ obj && $ obj instanceof Block && $ obj -> getParent ( ) && $ obj -> getParent ( ) -> getTemplate ( ) && $ obj -> getContent ( ) && $ obj -> getContentId ( ) != $ this -> content -> getId ( ) ) { return true ; } return false ; } | Skip blocks of a content item that are children of a template block and do not match the content id . The reason for this is that template blocks could have children from different content items |
14,223 | public function add ( Prototype $ prototype ) { if ( $ this -> has ( $ prototype -> getKey ( ) ) ) { throw new \ Exception ( sprintf ( 'A prototype with the key %s already exists' , $ prototype -> getKey ( ) ) ) ; } $ this -> collection [ ] = $ prototype ; } | Adds a prototype to the collection and increments the count . |
14,224 | public function has ( $ key ) { foreach ( $ this -> collection as $ prototype ) { if ( $ key == $ prototype -> getKey ( ) ) { return true ; } } return false ; } | Check if the collection has a prototype with the given key . |
14,225 | public function getAttribute ( $ name ) { foreach ( $ this -> attributes as $ attribute ) { if ( $ attribute -> getName ( ) == $ name ) { return $ attribute ; } } return false ; } | Get an attribute by its name |
14,226 | public function findLastUpdated ( $ limit = 5 ) { $ query = $ this -> createQueryBuilder ( 'c' ) -> orderBy ( 'c.updatedAt' , 'DESC' ) -> where ( 'c.layout = :layout' ) -> setParameter ( ':layout' , false ) -> setMaxResults ( $ limit ) -> getQuery ( ) ; return $ query -> getResult ( ) ; } | Find the last updated content items . |
14,227 | public function findLastCreated ( $ limit = 5 ) { $ query = $ this -> createQueryBuilder ( 'c' ) -> orderBy ( 'c.createdAt' , 'DESC' ) -> setMaxResults ( $ limit ) -> getQuery ( ) ; return $ query -> getResult ( ) ; } | Find the last created content items . |
14,228 | public function findIndexable ( ) { return $ this -> createQueryBuilder ( 'c' ) -> where ( 'c.indexable = :indexable' ) -> Andwhere ( 'c.active = :active' ) -> Andwhere ( 'c.layout = :layout' ) -> setParameters ( [ 'active' => true , 'layout' => false , 'indexable' => true ] ) -> orderBy ( 'c.slug' , 'ASC' ) -> getQuery ( ) -> getResult ( ) ; } | Find all active and addressable content items . |
14,229 | protected function summary ( $ signal , $ time_start , $ time_end , $ query_exec_time , $ exec_queries ) { $ this -> newLine ( ) ; $ this -> text ( sprintf ( '<info>%s</info> query process (%s s)' , $ signal , number_format ( $ query_exec_time , 4 ) ) ) ; $ this -> newLine ( ) ; $ this -> text ( sprintf ( '<comment>%s</comment>' , str_repeat ( '-' , 30 ) ) ) ; $ this -> newLine ( ) ; $ this -> text ( sprintf ( '<info>++</info> finished in %s s' , number_format ( ( $ time_end - $ time_start ) , 4 ) ) ) ; $ this -> text ( sprintf ( '<info>++</info> %s sql queries' , $ exec_queries ) ) ; } | Display in the console all the migration processes |
14,230 | public function reverseTransform ( $ value ) { if ( $ value instanceof Collection ) { return $ value ; } $ collection = new ArrayCollection ( ) ; if ( null !== $ value ) { $ collection -> add ( $ value ) ; } return $ collection ; } | Transforms a single Object to an ArrayCollection |
14,231 | protected function configure ( ) { parent :: configure ( ) ; $ this -> addOption ( 'host' , NULL , InputOption :: VALUE_OPTIONAL , 'The host address to serve the application on.' , 'localhost' ) -> addOption ( 'docroot' , NULL , InputOption :: VALUE_OPTIONAL , 'Specify an explicit document root.' , FALSE ) -> addOption ( 'port' , NULL , InputOption :: VALUE_OPTIONAL , 'The port to serve the application on.' , 8000 ) ; } | Command configuration method . Configure all the arguments and options . |
14,232 | public function sitemapAction ( ) { $ contents = $ this -> get ( 'opifer.content.content_manager' ) -> getRepository ( ) -> findIndexable ( ) ; $ event = new SitemapEvent ( ) ; foreach ( $ contents as $ content ) { $ event -> addUrl ( $ this -> generateUrl ( '_content' , [ 'slug' => $ content -> getSlug ( ) ] , UrlGeneratorInterface :: ABSOLUTE_URL ) , $ content -> getUpdatedAt ( ) ) ; } $ dispatcher = $ this -> get ( 'event_dispatcher' ) ; $ dispatcher -> dispatch ( Events :: POPULATE_SITEMAP , $ event ) ; return $ this -> render ( 'OpiferCmsBundle:Sitemap:sitemap.xml.twig' , [ 'urls' => $ event -> getUrls ( ) , ] ) ; } | Renders the sitemap . |
14,233 | public function getChildren ( ) { $ children = new ArrayCollection ( ) ; if ( $ this -> reference ) { $ children -> add ( $ this -> reference ) ; } return $ children ; } | Overrides the CompositeBlock s getChildren method to pass the reference as this block s children |
14,234 | public function getUrl ( MediaInterface $ media ) { $ metadata = $ media -> getMetaData ( ) ; return sprintf ( '%s?v=%s' , self :: WATCH_URL , $ metadata [ 'id' ] ) ; } | Get the full url to the original video . |
14,235 | protected function configure ( ) { $ this -> setName ( $ this -> name ) -> setDescription ( $ this -> description ) -> setAliases ( $ this -> aliases ) -> addOption ( 'env' , null , InputOption :: VALUE_REQUIRED , 'Set the environment variable file' , sprintf ( '%s/%s' , getcwd ( ) , '.craftsman' ) ) ; } | Configure default attributes |
14,236 | protected function initialize ( InputInterface $ input , OutputInterface $ output ) { try { $ this -> input = $ input ; $ this -> output = $ output ; $ this -> style = new SymfonyStyle ( $ input , $ output ) ; $ file = new \ SplFileInfo ( $ this -> getOption ( 'env' ) ) ; $ this -> env = new Dotenv ( $ file -> getPathInfo ( ) -> getRealPath ( ) , $ file -> getFilename ( ) ) ; $ this -> env -> load ( ) ; $ this -> env -> required ( [ 'BASEPATH' , 'APPPATH' ] ) -> notEmpty ( ) ; } catch ( Exception $ e ) { throw new \ RuntimeException ( $ e -> getMessage ( ) ) ; } } | Initialize the objects |
14,237 | public function createValuedQueryBuilder ( $ entityAlias ) { return $ this -> createQueryBuilder ( $ entityAlias ) -> select ( $ entityAlias , 'vs' , 'v' , 'a' , 'p' , 's' ) -> leftJoin ( $ entityAlias . '.valueSet' , 'vs' ) -> leftJoin ( 'vs.schema' , 's' ) -> leftJoin ( 'vs.values' , 'v' ) -> leftJoin ( 's.attributes' , 'a' ) -> leftJoin ( 'v.options' , 'p' ) ; } | Used by Elastica to transform results to model . |
14,238 | public function getContentFromRequest ( Request $ request ) { $ qb = $ this -> createValuedQueryBuilder ( 'c' ) ; if ( $ request -> get ( 'q' ) ) { $ qb -> leftJoin ( 'c.template' , 't' ) ; $ qb -> andWhere ( 'c.title LIKE :query OR c.alias LIKE :query OR c.slug LIKE :query OR t.displayName LIKE :query' ) ; $ qb -> setParameter ( 'query' , '%' . $ request -> get ( 'q' ) . '%' ) ; } if ( $ ids = $ request -> get ( 'ids' ) ) { $ ids = explode ( ',' , $ ids ) ; $ qb -> andWhere ( 'c.id IN (:ids)' ) -> setParameter ( 'ids' , $ ids ) ; } $ qb -> andWhere ( 'c.deletedAt IS NULL AND c.layout = :layout' ) ; $ qb -> setParameter ( 'layout' , false ) ; $ qb -> orderBy ( 'c.slug' ) ; return $ qb -> getQuery ( ) -> getResult ( ) ; } | Get a querybuilder by request . |
14,239 | public function findOneById ( $ id ) { $ query = $ this -> createValuedQueryBuilder ( 'c' ) -> where ( 'c.id = :id' ) -> setParameter ( 'id' , $ id ) -> getQuery ( ) ; return $ query -> useResultCache ( true , self :: CACHE_TTL ) -> getSingleResult ( ) ; } | Find one by ID . |
14,240 | public function findOneBySlug ( $ slug ) { $ query = $ this -> createQueryBuilder ( 'c' ) -> where ( 'c.slug = :slug' ) -> setParameter ( 'slug' , $ slug ) -> andWhere ( 'c.publishAt < :now OR c.publishAt IS NULL' ) -> andWhere ( 'c.active = :active' ) -> andWhere ( 'c.layout = :layout' ) -> setParameter ( 'now' , new \ DateTime ( ) ) -> setParameter ( 'active' , true ) -> setParameter ( 'layout' , false ) -> setMaxResults ( 1 ) -> getQuery ( ) ; return $ query -> useResultCache ( true , self :: CACHE_TTL ) -> getOneOrNullResult ( ) ; } | Find one by slug . |
14,241 | public function findOneByIdOrSlug ( $ idOrSlug , $ allow404 = false ) { if ( is_numeric ( $ idOrSlug ) ) { $ content = $ this -> find ( $ idOrSlug ) ; } else { $ content = $ this -> findOneBySlug ( $ idOrSlug ) ; } if ( ! $ content && $ allow404 == true ) { $ content = $ this -> findOneBySlug ( '404' ) ; } return $ content ; } | Finds a content item by its id or slug . |
14,242 | public function findActiveBySlug ( $ slug , $ host ) { $ query = $ this -> createValuedQueryBuilder ( 'c' ) -> leftJoin ( 'c.site' , 'os' ) -> leftJoin ( 'os.domains' , 'd' ) -> where ( 'c.slug = :slug' ) -> andWhere ( 'c.active = :active' ) -> andWhere ( 'c.layout = :layout' ) -> andWhere ( 'c.publishAt < :now OR c.publishAt IS NULL' ) -> andWhere ( 'd.domain = :host OR c.site IS NULL' ) -> setParameters ( [ 'slug' => $ slug , 'active' => true , 'layout' => false , 'now' => new \ DateTime ( ) , 'host' => $ host ] ) -> getQuery ( ) ; return $ query -> getSingleResult ( ) ; } | Find one by slug with active status . |
14,243 | public function findActiveByAlias ( $ alias , $ host ) { $ query = $ this -> createValuedQueryBuilder ( 'c' ) -> leftJoin ( 'c.site' , 'os' ) -> leftJoin ( 'os.domains' , 'd' ) -> where ( 'c.alias = :alias' ) -> andWhere ( 'c.active = :active' ) -> andWhere ( 'c.layout = :layout' ) -> andWhere ( '(c.publishAt < :now OR c.publishAt IS NULL)' ) -> andWhere ( 'd.domain = :host OR c.site IS NULL' ) -> setParameters ( [ 'alias' => $ alias , 'active' => true , 'layout' => false , 'now' => new \ DateTime ( ) , 'host' => $ host ] ) -> getQuery ( ) ; return $ query -> getSingleResult ( ) ; } | Find one by alias with active status . |
14,244 | public function findByIds ( $ ids ) { if ( ! is_array ( $ ids ) ) { $ ids = explode ( ',' , $ ids ) ; } if ( ! $ ids ) { return [ ] ; } return $ this -> createValuedQueryBuilder ( 'c' ) -> andWhere ( 'c.id IN (:ids)' ) -> setParameter ( 'ids' , $ ids ) -> andWhere ( 'c.deletedAt IS NULL' ) -> andWhere ( 'c.active = :active' ) -> andWhere ( 'c.layout = :layout' ) -> andWhere ( 'c.publishAt < :now OR c.publishAt IS NULL' ) -> setParameter ( 'now' , new \ DateTime ( ) ) -> setParameter ( 'active' , true ) -> setParameter ( 'layout' , false ) -> getQuery ( ) -> useResultCache ( true , self :: CACHE_TTL ) -> getResult ( ) ; } | Find content items by multiple ids . |
14,245 | private function sortByArray ( $ items , array $ order ) { $ unordered = [ ] ; foreach ( $ items as $ content ) { $ unordered [ $ content -> getId ( ) ] = $ content ; } $ ordered = [ ] ; foreach ( $ order as $ id ) { if ( isset ( $ unordered [ $ id ] ) ) { $ ordered [ ] = $ unordered [ $ id ] ; } } return $ ordered ; } | Sort the items by an array of ids . |
14,246 | public function findByLevels ( $ levels = 1 , $ ids = array ( ) ) { $ query = $ this -> createQueryBuilder ( 'c' ) ; if ( $ levels > 0 ) { $ selects = [ 'c' ] ; for ( $ i = 1 ; $ i <= $ levels ; ++ $ i ) { $ selects [ ] = 'c' . $ i ; } $ query -> select ( $ selects ) ; for ( $ i = 1 ; $ i <= $ levels ; ++ $ i ) { $ previous = ( $ i - 1 == 0 ) ? '' : ( $ i - 1 ) ; $ query -> leftJoin ( 'c' . $ previous . '.children' , 'c' . $ i , 'WITH' , 'c' . $ i . '.active = :active AND c' . $ i . '.showInNavigation = :show' ) ; } } if ( $ ids ) { $ query -> andWhere ( 'c.id IN (:ids)' ) -> setParameter ( 'ids' , $ ids ) ; } else { $ query -> andWhere ( 'c.parent IS NULL' ) ; } $ query -> andWhere ( 'c.active = :active' ) -> setParameter ( 'active' , true ) ; $ query -> andWhere ( 'c.layout = :layout' ) -> setParameter ( 'layout' , false ) ; $ query -> andWhere ( 'c.showInNavigation = :show' ) -> setParameter ( 'show' , true ) ; return $ query -> getQuery ( ) -> getResult ( ) ; } | Joins and selects the toplevel content items and its children recursively . |
14,247 | public function sortSearchResults ( $ results , $ term ) { $ sortedResults = [ ] ; if ( ! empty ( $ results ) ) { foreach ( $ results as $ result ) { if ( stripos ( $ result -> getTitle ( ) , $ term ) !== false ) { array_unshift ( $ sortedResults , $ result ) ; } else { $ sortedResults [ ] = $ result ; } } } return $ sortedResults ; } | Sort search results by giving priority to founded by title . |
14,248 | public function setState ( $ newState ) { if ( $ newState === $ this -> state ) { return ; } switch ( $ newState ) { case self :: STATE_RUNNING : $ this -> startedAt = new \ DateTime ( ) ; break ; case self :: STATE_FINISHED : case self :: STATE_FAILED : case self :: STATE_TERMINATED : $ this -> endedAt = new \ DateTime ( ) ; break ; default : break ; } $ this -> state = $ newState ; return $ this ; } | Set state . |
14,249 | public function getNextRunDate ( $ currentTime = 'now' , $ nth = 0 , $ allowCurrentDate = false ) { return $ this -> getCronExpression ( ) -> getNextRunDate ( $ currentTime , $ nth , $ allowCurrentDate ) ; } | Get a next run date relative to the current date or a specific date . |
14,250 | public function getPreviousRunDate ( $ currentTime = 'now' , $ nth = 0 , $ allowCurrentDate = false ) { return $ this -> getCronExpression ( ) -> getPreviousRunDate ( $ currentTime , $ nth , $ allowCurrentDate ) ; } | Get a previous run date relative to the current date or a specific date . |
14,251 | public function getMultipleRunDates ( $ total , $ currentTime = 'now' , $ invert = false , $ allowCurrentDate = false ) { return $ this -> getCronExpression ( ) -> getMultipleRunDates ( $ total , $ currentTime , $ invert , $ allowCurrentDate ) ; } | Get multiple run dates starting at the current date or a specific date . |
14,252 | public function getValue ( ) { $ options = parent :: getValue ( ) ; if ( count ( $ options ) ) { if ( empty ( $ options [ 0 ] ) ) { $ collection = $ options -> getValues ( ) ; return $ collection [ 0 ] -> getName ( ) ; } return $ options [ 0 ] -> getName ( ) ; } return '' ; } | Get the selected value |
14,253 | public function editAction ( Request $ request , $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ user = $ em -> getRepository ( 'OpiferCmsBundle:User' ) -> find ( $ id ) ; $ form = $ this -> createForm ( UserFormType :: class , $ user ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { if ( $ user -> isTwoFactorEnabled ( ) == false ) { $ user -> setGoogleAuthenticatorSecret ( null ) ; } $ this -> get ( 'fos_user.user_manager' ) -> updateUser ( $ user , true ) ; $ this -> addFlash ( 'success' , $ this -> get ( 'translator' ) -> trans ( 'user.edit.success' , [ '%username%' => ucfirst ( $ user -> getUsername ( ) ) , ] ) ) ; return $ this -> redirectToRoute ( 'opifer_cms_user_index' ) ; } return $ this -> render ( 'OpiferCmsBundle:Backend/User:edit.html.twig' , [ 'form' => $ form -> createView ( ) , 'user' => $ user , ] ) ; } | Edit a user . |
14,254 | public function profileAction ( Request $ request ) { $ user = $ this -> getUser ( ) ; $ form = $ this -> createForm ( ProfileType :: class , $ user ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { if ( $ user -> isTwoFactorEnabled ( ) == false ) { $ user -> setGoogleAuthenticatorSecret ( null ) ; } $ this -> get ( 'fos_user.user_manager' ) -> updateUser ( $ user , true ) ; if ( $ user -> isTwoFactorEnabled ( ) == true && empty ( $ user -> getGoogleAuthenticatorSecret ( ) ) ) { return $ this -> redirectToRoute ( 'opifer_cms_user_activate_2fa' ) ; } $ this -> addFlash ( 'success' , 'Your profile was updated successfully!' ) ; return $ this -> redirectToRoute ( 'opifer_cms_user_profile' ) ; } return $ this -> render ( 'OpiferCmsBundle:Backend/User:profile.html.twig' , [ 'form' => $ form -> createView ( ) , 'user' => $ user , ] ) ; } | Edit the current users profile . |
14,255 | public function activateGoogleAuthAction ( Request $ request ) { $ user = $ this -> getUser ( ) ; $ secret = $ this -> container -> get ( "scheb_two_factor.security.google_authenticator" ) -> generateSecret ( ) ; $ user -> setGoogleAuthenticatorSecret ( $ secret ) ; $ qrUrl = $ this -> container -> get ( "scheb_two_factor.security.google_authenticator" ) -> getUrl ( $ user ) ; $ form = $ this -> createForm ( GoogleAuthType :: class , $ user ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ this -> get ( 'fos_user.user_manager' ) -> updateUser ( $ user , true ) ; $ this -> addFlash ( 'success' , 'Your profile was updated successfully!' ) ; return $ this -> redirectToRoute ( 'opifer_cms_user_profile' ) ; } return $ this -> render ( 'OpiferCmsBundle:Backend/User:google_auth.html.twig' , [ 'form' => $ form -> createView ( ) , 'secret' => $ secret , 'user' => $ user , 'qrUrl' => $ qrUrl , ] ) ; } | Activate Google Authenticator |
14,256 | public function getService ( $ block ) { $ blockType = ( $ block instanceof BlockInterface ) ? $ block -> getBlockType ( ) : $ block ; if ( ! isset ( $ this -> services [ $ blockType ] ) ) { throw new \ Exception ( sprintf ( "No BlockService available by the alias %s, available: %s" , $ blockType , implode ( ', ' , array_keys ( $ this -> services ) ) ) ) ; } return $ this -> services [ $ blockType ] ; } | Returns the block service |
14,257 | public function find ( $ id , $ draft = false ) { if ( $ draft ) { $ this -> setDraftVersionFilter ( ! $ draft ) ; } $ block = $ this -> getRepository ( ) -> find ( $ id ) ; if ( $ draft ) { if ( null !== $ revision = $ this -> revisionManager -> getDraftRevision ( $ block ) ) { $ this -> revisionManager -> revert ( $ block , $ revision ) ; } } return $ block ; } | Find a Block in the repository with optional specified version . |
14,258 | public function findById ( $ id , $ draft = true ) { if ( $ draft ) { $ this -> setDraftVersionFilter ( ! $ draft ) ; } $ blocks = $ this -> getRepository ( ) -> findById ( $ id ) ; if ( $ draft ) { foreach ( $ blocks as $ block ) { if ( null !== $ revision = $ this -> revisionManager -> getDraftRevision ( $ block ) ) { $ this -> revisionManager -> revert ( $ block , $ revision ) ; } } } return $ blocks ; } | Find a Block in the repository in optional draft |
14,259 | public function findDescendants ( $ parent , $ draft = true ) { $ this -> setDraftVersionFilter ( ! $ draft ) ; $ iterator = new \ RecursiveIteratorIterator ( new RecursiveBlockIterator ( [ $ parent ] ) , \ RecursiveIteratorIterator :: SELF_FIRST ) ; $ blocks = [ ] ; foreach ( $ iterator as $ descendant ) { $ blocks [ ] = $ descendant ; } if ( $ draft ) { $ this -> revertToDraft ( $ blocks ) ; } return $ blocks ; } | Finds the block and all its children recursively |
14,260 | public function publish ( $ blocks ) { if ( $ blocks instanceof PersistentCollection ) { $ blocks = $ blocks -> getValues ( ) ; } if ( ! $ blocks || ( is_array ( $ blocks ) && ! count ( $ blocks ) ) ) { return ; } if ( ! is_array ( $ blocks ) ) { $ blocks = [ $ blocks ] ; } $ this -> disableRevisionListener ( ) ; $ deletes = [ ] ; foreach ( $ blocks as $ block ) { if ( null !== $ revision = $ this -> revisionManager -> getDraftRevision ( $ block ) ) { try { $ this -> revisionManager -> revert ( $ block , $ revision ) ; } catch ( DeletedException $ e ) { $ deletes [ ] = $ block ; } } } $ this -> em -> flush ( ) ; foreach ( $ deletes as $ block ) { if ( $ block instanceof CompositeBlock ) { $ descendants = $ this -> findDescendants ( $ block , false ) ; } else { $ descendants = [ $ block ] ; } foreach ( $ descendants as $ descendant ) { $ descendant -> setDeletedAt ( new \ DateTime ) ; $ this -> em -> flush ( $ descendant ) ; } } $ cacheDriver = $ this -> em -> getConfiguration ( ) -> getResultCacheImpl ( ) ; $ cacheDriver -> deleteAll ( ) ; $ this -> enableRevisionListener ( ) ; } | Publishes a block |
14,261 | public function duplicate ( $ blocks , $ owner = null ) { if ( $ blocks instanceof BlockInterface ) { $ blocks = array ( $ blocks ) ; } $ iterator = new \ RecursiveIteratorIterator ( new RecursiveBlockIterator ( $ blocks ) , \ RecursiveIteratorIterator :: SELF_FIRST ) ; $ originalIdMap = array ( ) ; $ originalParentMap = array ( ) ; $ clones = array ( ) ; foreach ( $ iterator as $ block ) { $ blockId = $ block -> getId ( ) ; $ parentId = false ; if ( in_array ( $ block -> getId ( ) , $ originalIdMap ) ) { continue ; } $ clone = clone $ block ; $ clone -> setId ( null ) ; $ clone -> setParent ( null ) ; $ clone -> setOwner ( $ owner ) ; if ( $ block -> getParent ( ) ) { $ parentId = $ block -> getParent ( ) -> getId ( ) ; } if ( $ clone instanceof BlockContainerInterface ) { $ clone -> setChildren ( null ) ; } $ this -> em -> persist ( $ clone ) ; $ this -> em -> flush ( $ clone ) ; $ originalIdMap [ $ clone -> getId ( ) ] = $ blockId ; if ( $ parentId ) { $ originalParentMap [ $ clone -> getId ( ) ] = $ parentId ; } $ clones [ ] = $ clone ; } foreach ( $ clones as $ clone ) { if ( isset ( $ originalParentMap [ $ clone -> getId ( ) ] ) ) { foreach ( $ clones as $ parent ) { if ( isset ( $ originalParentMap [ $ clone -> getId ( ) ] ) && $ originalParentMap [ $ clone -> getId ( ) ] === $ originalIdMap [ $ parent -> getId ( ) ] ) { $ clone -> setParent ( $ parent ) ; $ parent -> addChild ( $ clone ) ; $ this -> em -> flush ( $ clone ) ; $ this -> em -> flush ( $ parent ) ; } } } } return $ clones ; } | Clones blocks and persists to database |
14,262 | public function setDraftVersionFilter ( $ enabled = true ) { if ( $ this -> em -> getFilters ( ) -> isEnabled ( 'draft' ) && ! $ enabled ) { $ this -> em -> getFilters ( ) -> disable ( 'draft' ) ; } else if ( ! $ this -> em -> getFilters ( ) -> isEnabled ( 'draft' ) && $ enabled ) { $ this -> em -> getFilters ( ) -> enable ( 'draft' ) ; } } | Kills the DraftVersionFilter |
14,263 | public function disableRevisionListener ( ) { foreach ( $ this -> em -> getEventManager ( ) -> getListeners ( ) as $ event => $ listeners ) { foreach ( $ listeners as $ hash => $ listener ) { if ( $ listener instanceof RevisionListener ) { $ this -> revisionListener = $ listener ; break 2 ; } } } if ( $ this -> revisionListener ) { $ this -> revisionListener -> setActive ( false ) ; } } | Removes the RevisionListener from the EventManager |
14,264 | public function getSiblings ( BlockInterface $ block , $ version = false ) { $ owner = $ block -> getOwner ( ) ; $ family = $ this -> findByOwner ( $ owner , $ version ) ; $ siblings = array ( ) ; foreach ( $ family as $ member ) { if ( $ member -> getParent ( ) && $ member -> getParent ( ) -> getId ( ) == $ block -> getParent ( ) -> getId ( ) ) { array_push ( $ siblings , $ member ) ; } } return $ siblings ; } | Gets the Block nodes siblings at a version . |
14,265 | public function match ( $ pathinfo ) { $ urlMatcher = new UrlMatcher ( $ this -> routeCollection , $ this -> getContext ( ) ) ; $ result = $ urlMatcher -> match ( $ pathinfo ) ; return $ result ; } | Matches anything . |
14,266 | public function postLoad ( LifeCycleEventArgs $ args ) { $ entity = $ args -> getEntity ( ) ; if ( $ entity instanceof ValueSetInterface && $ entity -> getValues ( ) !== null ) { $ this -> eavManager -> replaceEmptyValues ( $ entity ) ; } } | Create empty values for non - persisted values . |
14,267 | public function postPersist ( LifeCycleEventArgs $ args ) { $ entity = $ args -> getEntity ( ) ; $ entityManager = $ args -> getEntityManager ( ) ; if ( $ entity instanceof ValueInterface && $ entity -> isEmpty ( ) ) { $ entityManager -> remove ( $ entity ) ; } } | Remove empty values after persisting to avoid null Value values in the database . |
14,268 | public function findByRequest ( Request $ request ) { $ qb = $ this -> createQueryBuilder ( 's' ) ; if ( $ request -> get ( 'attribute' ) ) { $ qb -> join ( 's.allowedInAttributes' , 'a' ) -> andWhere ( 'a.id = :attributeId' ) -> setParameter ( 'attributeId' , $ request -> get ( 'attribute' ) ) ; } return $ qb -> getQuery ( ) -> getArrayResult ( ) ; } | Find schemas by request |
14,269 | public function addValue ( ValueProviderInterface $ value , $ alias ) { if ( false === $ value -> isEnabled ( ) ) { return ; } $ this -> values [ $ alias ] = $ value ; } | Adds all the values tagged with opifer . media . value to the value pool |
14,270 | public function getValueByEntity ( $ entity ) { if ( is_object ( $ entity ) ) { $ entity = get_class ( $ entity ) ; } foreach ( $ this -> getValues ( ) as $ provider ) { if ( $ entity === $ provider -> getEntity ( ) ) { return $ provider ; } } return false ; } | Get a valueprovider by it s entity class |
14,271 | public function registerAssetFiles ( $ view ) { if ( is_array ( self :: $ _assets ) ) { $ this -> css = array_values ( array_intersect_key ( self :: $ _css , self :: $ _assets ) ) ; $ this -> js = array_values ( array_intersect_key ( self :: $ _js , self :: $ _assets ) ) ; } array_unshift ( $ this -> css , self :: $ _css [ 'lib' ] ) ; array_unshift ( $ this -> js , self :: $ _js [ 'lib' ] ) ; parent :: registerAssetFiles ( $ view ) ; } | Registers the CSS and JS files with the given view . |
14,272 | public function getDefaultDomain ( ) { if ( $ this -> defaultDomain ) { return $ this -> defaultDomain ; } elseif ( $ first = $ this -> getDomains ( ) -> first ( ) ) { return $ first -> getDomain ( ) ; } else { return null ; } } | Get defaultDomain . |
14,273 | public function request ( $ name , array $ arguments , array $ options = null , $ inputHeaders = null ) { $ soapRequest = $ this -> interpreter -> request ( $ name , $ arguments , $ options , $ inputHeaders ) ; if ( $ soapRequest -> getSoapVersion ( ) == '1' ) { $ this -> builder -> isSOAP11 ( ) ; } else { $ this -> builder -> isSOAP12 ( ) ; } $ this -> builder -> setEndpoint ( $ soapRequest -> getEndpoint ( ) ) ; $ this -> builder -> setSoapAction ( $ soapRequest -> getSoapAction ( ) ) ; $ stream = new Stream ( 'php://temp' , 'r+' ) ; $ stream -> write ( $ soapRequest -> getSoapMessage ( ) ) ; $ stream -> rewind ( ) ; $ this -> builder -> setSoapMessage ( $ stream ) ; try { return $ this -> builder -> getSoapHttpRequest ( ) ; } catch ( RequestException $ exception ) { $ stream -> close ( ) ; throw $ exception ; } } | Embed SOAP messages in PSR - 7 HTTP Requests |
14,274 | public function response ( ResponseInterface $ response , $ name , array & $ outputHeaders = null ) { return $ this -> interpreter -> response ( $ response -> getBody ( ) -> __toString ( ) , $ name , $ outputHeaders ) ; } | Retrieve SOAP messages from PSR - 7 HTTP responses and interpret messages to PHP values . |
14,275 | public function create ( $ name , $ value ) { if ( ! empty ( $ this -> callbacks [ $ name ] ) ) { return call_user_func ( $ this -> callbacks [ $ name ] , $ name , $ value ) ; } return $ this -> createBasic ( $ name , $ value ) ; } | Create a new claim |
14,276 | public function clipboardBlockAction ( $ id ) { $ manager = $ this -> get ( 'opifer.content.block_manager' ) ; $ clipboardService = $ this -> get ( 'opifer.content.clipboard_block' ) ; $ response = new JsonResponse ; try { $ block = $ manager -> find ( $ id , true ) ; $ clipboardService -> addToClipboard ( $ block ) ; $ blockService = $ manager -> getService ( $ block ) ; $ response -> setData ( [ 'message' => sprintf ( '%s copied to clipboard' , $ blockService -> getName ( ) ) ] ) ; } catch ( \ Exception $ e ) { $ response -> setStatusCode ( 500 ) ; $ response -> setData ( [ 'error' => $ e -> getMessage ( ) ] ) ; } return $ response ; } | Copies a reference of a block to the clipboard |
14,277 | public function publishSharedAction ( Request $ request ) { $ this -> getDoctrine ( ) -> getManager ( ) -> getFilters ( ) -> disable ( 'draft' ) ; $ manager = $ this -> get ( 'opifer.content.block_manager' ) ; $ response = new JsonResponse ; $ id = ( int ) $ request -> request -> get ( 'id' ) ; try { $ block = $ manager -> find ( $ id , true ) ; $ block -> setUpdatedAt ( new \ DateTime ( ) ) ; $ manager -> publish ( $ block ) ; if ( $ block instanceof CompositeBlock ) { $ manager -> publish ( $ manager -> findDescendants ( $ block ) ) ; } $ response -> setStatusCode ( 200 ) ; $ response -> setData ( [ 'state' => 'published' ] ) ; } catch ( \ Exception $ e ) { $ response -> setStatusCode ( 500 ) ; $ response -> setData ( [ 'error' => $ e -> getMessage ( ) . $ e -> getTraceAsString ( ) ] ) ; } return $ response ; } | Publishes a shared block and it s members |
14,278 | public function discardBlockAction ( Request $ request ) { $ this -> getDoctrine ( ) -> getManager ( ) -> getFilters ( ) -> disable ( 'draft' ) ; $ manager = $ this -> get ( 'opifer.content.block_manager' ) ; $ response = new JsonResponse ; $ id = ( int ) $ request -> request -> get ( 'id' ) ; try { $ manager -> discardAll ( $ id ) ; $ response -> setStatusCode ( 200 ) ; $ response -> setData ( [ 'state' => 'discarded' ] ) ; } catch ( \ Exception $ e ) { $ response -> setStatusCode ( 500 ) ; $ response -> setData ( [ 'error' => $ e -> getMessage ( ) ] ) ; } return $ response ; } | Discards all changes to block and it s members |
14,279 | public function findPendingSynchronisation ( ) { return $ this -> createQueryBuilder ( 's' ) -> innerjoin ( 's.mailingList' , 'm' ) -> andWhere ( 's.status = :pending OR s.status = :failed' ) -> setParameters ( [ 'pending' => Subscription :: STATUS_PENDING , 'failed' => Subscription :: STATUS_FAILED , ] ) -> getQuery ( ) -> getResult ( ) ; } | Finds all subscriptions pending synchronisation . |
14,280 | public function findPendingSynchronisationList ( MailingList $ mailingList ) { return $ this -> createQueryBuilder ( 's' ) -> innerjoin ( 's.mailingList' , 'm' ) -> where ( 's.mailingList = :mailingList' ) -> andWhere ( 's.status = :pending OR s.status = :failed' ) -> setParameters ( [ 'mailingList' => $ mailingList , 'pending' => Subscription :: STATUS_PENDING , 'failed' => Subscription :: STATUS_FAILED , ] ) -> getQuery ( ) -> getResult ( ) ; } | Finds all subscriptions pending synchronisation for a specific mailinglist . |
14,281 | public function getOptionByName ( $ name ) { foreach ( $ this -> options as $ option ) { if ( $ option -> getName ( ) == $ name ) { return $ option ; } } return false ; } | Get an option by its name . |
14,282 | public function addAllowedSchema ( SchemaInterface $ schema ) { $ exists = false ; foreach ( $ this -> allowedSchemas as $ allowedSchema ) { if ( $ allowedSchema -> getId ( ) == $ schema -> getId ( ) ) { $ exists = true ; } } if ( ! $ exists ) { $ this -> allowedSchemas [ ] = $ schema ; } return $ this ; } | Add allowed schema . |
14,283 | protected function mapClassParameters ( array $ classes , ContainerBuilder $ container ) { foreach ( $ classes as $ model => $ serviceClasses ) { foreach ( $ serviceClasses as $ service => $ class ) { $ container -> setParameter ( sprintf ( 'opifer_cms.%s_%s' , $ model , $ service ) , $ class ) ; } } } | Remap class parameters . |
14,284 | public function createFormView ( FormInterface $ form ) { $ post = $ this -> eavManager -> initializeEntity ( $ form -> getSchema ( ) ) ; $ form = $ this -> formFactory -> create ( PostType :: class , $ post , [ 'form_id' => $ form -> getId ( ) ] ) ; return $ form -> createView ( ) ; } | Builds a Symfony form from the passed Form entity and returns the related FormView so we can use our Form as a standard Symfony form in our templates . |
14,285 | public function viewAction ( $ id ) { $ manager = $ this -> get ( 'opifer.content.block_manager' ) ; $ block = $ manager -> getRepository ( ) -> find ( $ id ) ; if ( ! $ block ) { throw $ this -> createNotFoundException ( ) ; } $ response = new Response ( ) ; $ environment = $ this -> get ( 'opifer.content.block_environment' ) ; $ environment -> setObject ( $ block -> getOwner ( ) ) ; $ service = $ manager -> getService ( $ block ) ; $ response = $ service -> execute ( $ block , $ response , [ 'partial' => true , 'environment' => $ environment ] ) ; return $ response ; } | Renders a single block |
14,286 | public function sharedAction ( ) { $ blocks = $ this -> get ( 'opifer.content.block_manager' ) -> getRepository ( ) -> findBy ( [ 'shared' => true ] ) ; return $ this -> render ( $ this -> getParameter ( 'opifer_content.block_shared_view' ) , [ 'blocks' => $ blocks , ] ) ; } | Block shared view . |
14,287 | protected function setChildren ( Block $ block ) { if ( method_exists ( $ block , 'setChildren' ) ) { $ children = $ this -> environment -> getBlockChildren ( $ block ) ; $ block -> setChildren ( $ children ) ; } } | Maps the block children from the environment to the block |
14,288 | public function indexAction ( ) { $ contentTypes = $ this -> get ( 'opifer.content.content_type_manager' ) -> getRepository ( ) -> findAll ( ) ; return $ this -> render ( $ this -> getParameter ( 'opifer_content.content_type_index_view' ) , [ 'content_types' => $ contentTypes , ] ) ; } | ContentType index view . |
14,289 | public function createAction ( Request $ request ) { $ contentTypeManager = $ this -> get ( 'opifer.content.content_type_manager' ) ; $ contentType = $ contentTypeManager -> create ( ) ; $ form = $ this -> createForm ( ContentTypeType :: class , $ contentType ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { foreach ( $ form -> getData ( ) -> getSchema ( ) -> getAttributes ( ) as $ attribute ) { $ attribute -> setSchema ( $ contentType -> getSchema ( ) ) ; foreach ( $ attribute -> getOptions ( ) as $ option ) { $ option -> setAttribute ( $ attribute ) ; } } $ contentTypeManager -> save ( $ contentType ) ; $ this -> addFlash ( 'success' , 'Content type has been created successfully' ) ; return $ this -> redirectToRoute ( 'opifer_content_contenttype_edit' , [ 'id' => $ contentType -> getId ( ) ] ) ; } return $ this -> render ( $ this -> getParameter ( 'opifer_content.content_type_create_view' ) , [ 'content_type' => $ contentType , 'form' => $ form -> createView ( ) , ] ) ; } | Create a ContentType . |
14,290 | public function contentAction ( Request $ request ) { return $ this -> render ( 'OpiferCmsBundle:CKEditor:content.html.twig' , [ 'funcNum' => $ request -> get ( 'CKEditorFuncNum' ) , 'CKEditor' => $ request -> get ( 'CKEditor' ) , 'type' => $ request -> get ( 'type' ) , ] ) ; } | Content browser for CKEditor . |
14,291 | public function mediaAction ( Request $ request ) { $ providers = $ this -> get ( 'opifer.media.provider.pool' ) -> getProviders ( ) ; return $ this -> render ( 'OpiferCmsBundle:CKEditor:media.html.twig' , [ 'providers' => $ providers , 'funcNum' => $ request -> get ( 'CKEditorFuncNum' ) , 'CKEditor' => $ request -> get ( 'CKEditor' ) , 'type' => $ request -> get ( 'type' ) , ] ) ; } | Image browser for CKEditor . |
14,292 | protected function isLocked ( Cron $ cron ) { $ hourAgo = new \ DateTime ( '-65 minutes' ) ; if ( $ cron -> getState ( ) === Cron :: STATE_RUNNING && $ cron -> getStartedAt ( ) > $ hourAgo ) { return true ; } return false ; } | Checks if the cronjob is currently locked . |
14,293 | private function startCron ( Cron $ cron ) { if ( $ this -> isLocked ( $ cron ) ) { return ; } $ this -> output -> writeln ( sprintf ( 'Started %s.' , $ cron ) ) ; $ this -> changeState ( $ cron , Cron :: STATE_RUNNING ) ; $ pb = $ this -> getCommandProcessBuilder ( ) ; $ parts = explode ( ' ' , $ cron -> getCommand ( ) ) ; foreach ( $ parts as $ part ) { $ pb -> add ( $ part ) ; } $ process = $ pb -> getProcess ( ) ; $ process -> setTimeout ( 3600 ) ; try { $ process -> mustRun ( ) ; $ this -> output -> writeln ( ' > ' . $ process -> getOutput ( ) ) ; if ( ! $ process -> isSuccessful ( ) ) { $ this -> output -> writeln ( ' > ' . $ process -> getErrorOutput ( ) ) ; if ( strpos ( $ process -> getErrorOutput ( ) , 'timeout' ) !== false ) { $ this -> changeState ( $ cron , Cron :: STATE_TERMINATED , $ process -> getErrorOutput ( ) ) ; } else { $ this -> changeState ( $ cron , Cron :: STATE_FAILED , $ process -> getErrorOutput ( ) ) ; } } else { $ this -> changeState ( $ cron , Cron :: STATE_FINISHED ) ; } } catch ( \ Exception $ e ) { $ message = $ e -> getMessage ( ) ; if ( strpos ( $ e -> getMessage ( ) , 'timeout' ) !== false ) { $ this -> output -> writeln ( ' > ' . $ e -> getMessage ( ) ) ; $ this -> changeState ( $ cron , Cron :: STATE_TERMINATED , $ e -> getMessage ( ) ) ; } else { $ this -> output -> writeln ( ' > ' . $ e -> getMessage ( ) ) ; $ this -> changeState ( $ cron , Cron :: STATE_FAILED , $ e -> getMessage ( ) ) ; } } } | Start a cron . |
14,294 | private function changeState ( Cron $ cron , $ state , $ lastError = null ) { $ cron -> setState ( $ state ) ; $ cron -> setLastError ( $ lastError ) ; $ em = $ this -> getEntityManager ( ) ; $ em -> persist ( $ cron ) ; $ em -> flush ( $ cron ) ; } | Change the state of the cron . |
14,295 | private function getCommandProcessBuilder ( ) { $ pb = new ProcessBuilder ( ) ; if ( ! defined ( 'PHP_WINDOWS_VERSION_MAJOR' ) ) { $ pb -> add ( 'exec' ) ; } $ pb -> add ( 'php' ) -> add ( $ this -> getContainer ( ) -> getParameter ( 'kernel.root_dir' ) . '/console' ) -> add ( '--env=' . $ this -> env ) ; return $ pb ; } | Get the process builder . |
14,296 | public function findByIds ( $ ids ) { if ( ! is_array ( $ ids ) ) { $ ids = explode ( ',' , trim ( $ ids ) ) ; } return $ this -> createQueryBuilder ( 'o' ) -> where ( 'o.id IN (:ids)' ) -> setParameters ( [ 'ids' => $ ids , ] ) -> getQuery ( ) -> getResult ( ) ; } | Find all options by an array or comma - separated list of ids . |
14,297 | protected function initOptions ( ) { $ view = Yii :: $ app -> view ; $ opts = [ 'confirmButtonText' => Yii :: t ( 'sweetsubmit' , 'Ok' ) , 'cancelButtonText' => Yii :: t ( 'sweetsubmit' , 'Cancel' ) , ] ; $ opts = Json :: encode ( $ opts ) ; $ view -> registerJs ( "yii.sweetSubmitOptions = $opts;" , View :: POS_END ) ; } | Init plugin optins . |
14,298 | public function error404Action ( Request $ request ) { $ host = $ request -> getHost ( ) ; $ slugParts = explode ( '/' , $ request -> getPathInfo ( ) ) ; $ locale = $ this -> getDoctrine ( ) -> getRepository ( Locale :: class ) -> findOneByLocale ( $ slugParts [ 1 ] ) ; $ contentRepository = $ this -> getDoctrine ( ) -> getRepository ( 'OpiferCmsBundle:Content' ) ; $ content = $ contentRepository -> findActiveBySlug ( '404' , $ host ) ; if ( ! $ content ) { $ content = $ contentRepository -> findOneBySlug ( $ locale -> getLocale ( ) . '/404' ) ; } if ( ! $ content ) { $ content = $ contentRepository -> findOneBySlug ( '404' ) ; } if ( $ content ) { return $ this -> forward ( 'OpiferContentBundle:Frontend/Content:view' , [ 'content' => $ content , 'statusCode' => 404 , ] ) ; } $ response = new Response ( ) ; $ response -> setStatusCode ( 404 ) ; return $ this -> render ( 'OpiferCmsBundle:Exception:error404.html.twig' , [ ] , $ response ) ; } | 404 error page . |
14,299 | protected function transform ( Expression $ expression ) { $ constraint = $ expression -> getConstraint ( ) ; $ getter = 'get' . ucfirst ( $ expression -> getSelector ( ) ) ; return Expr :: method ( $ getter , new $ constraint ( $ expression -> getValue ( ) ) ) ; } | Transform the expression to Webmozarts Expression . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.