idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
50,300
public function calendarUrlArray ( array $ url , ChronosInterface $ dateTime ) { $ year = $ this -> retrieveYearFromDate ( $ dateTime ) ; $ month = $ this -> retrieveMonthFromDate ( $ dateTime ) ; $ currentYear = ( int ) date ( 'Y' ) ; $ currentMonth = ( int ) date ( 'n' ) ; if ( $ year === ( int ) $ currentYear && $ month === ( int ) $ currentMonth ) { return $ url ; } $ url [ ] = $ year ; $ url [ ] = $ this -> formatMonth ( $ month ) ; return $ url ; }
Generates a link back to the calendar from any view page .
50,301
public function readFile ( $ filename ) { if ( is_file ( $ filename ) === false ) { throw new FileNotFoundException ( sprintf ( 'File "%s" does not exist.' , $ filename ) ) ; } if ( is_readable ( $ filename ) === false ) { throw new IOException ( sprintf ( 'File "%s" cannot be read.' , $ filename ) ) ; } $ content = file_get_contents ( $ filename ) ; if ( $ content === false ) { throw new IOException ( sprintf ( 'Error reading the content of the file "%s".' , $ filename ) ) ; } return $ content ; }
Reads the content of a filename .
50,302
public function addConverter ( ConverterInterface $ converter ) { $ priority = $ converter -> getPriority ( ) ; if ( false === ( is_int ( $ priority ) && $ priority >= 0 && $ priority <= 10 ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid priority at the converter: "%s".' , get_class ( $ converter ) ) ) ; } $ this -> queue -> insert ( $ converter , $ priority ) ; }
Adds a converter .
50,303
public function convertContent ( $ content , $ inputExtension ) { $ converter = $ this -> getConverter ( $ inputExtension ) ; $ content = $ converter -> convert ( $ content ) ; $ outputExtension = $ converter -> getOutExtension ( $ inputExtension ) ; return new ConverterResult ( $ content , $ inputExtension , $ outputExtension ) ; }
Converts the content .
50,304
public function convertItem ( ItemInterface $ item ) { $ path = $ item -> getPath ( ItemInterface :: SNAPSHOT_PATH_RELATIVE ) ; $ str = new StringWrapper ( $ path ) ; $ extension = $ str -> getFirstEndMatch ( $ this -> textExtensions ) ; if ( $ extension === '' ) { $ extension = pathinfo ( $ path , PATHINFO_EXTENSION ) ; } return $ this -> convertContent ( $ item -> getContent ( ) , $ extension ) ; }
Converts an item . This method uses the SNAPSHOT_PATH_RELATIVE of Item path .
50,305
public function buildFromConfigArray ( array $ config ) { $ cm = new CollectionManager ( ) ; $ collectionItemCollection = $ cm -> getCollectionItemCollection ( ) ; foreach ( $ config as $ collectionName => $ attributes ) { $ path = $ collectionName === 'pages' ? '' : $ collectionName ; if ( is_array ( $ attributes ) === false ) { throw new \ RuntimeException ( sprintf ( 'Expected array at the collection: "%s".' , $ collectionName ) ) ; } $ collectionItemCollection -> set ( $ collectionName , new Collection ( $ collectionName , $ path , $ attributes ) ) ; } return $ cm ; }
Build a collection manager with collections loaded from config array .
50,306
protected function setTermsPermalink ( array $ items , $ taxonomyAttribute , array $ terms , $ termRelativePath ) { foreach ( $ items as $ item ) { $ attributes = $ item -> getAttributes ( ) ; if ( isset ( $ attributes [ 'term_urls' ] ) ) { $ attributes [ 'term_urls' ] = [ ] ; } if ( isset ( $ attributes [ 'term_urls' ] [ $ taxonomyAttribute ] ) ) { $ attributes [ 'term_urls' ] [ $ taxonomyAttribute ] = [ ] ; } $ slugedTermPermalink = $ this -> getTermPermalink ( $ termRelativePath ) ; foreach ( $ terms as $ term ) { $ attributes [ 'terms_url' ] [ $ taxonomyAttribute ] [ $ term ] = $ slugedTermPermalink ; } $ item -> setAttributes ( $ attributes ) ; } }
Sets the permalink s term to a list of items associated with that term .
50,307
protected function getTermRelativePath ( $ basePath , $ permalinkTemplate , $ term ) { $ result = $ basePath ; $ slugedTerm = ( new StringWrapper ( $ term ) ) -> slug ( ) ; $ result .= '/' . str_replace ( ':name' , $ slugedTerm , $ permalinkTemplate ) . '/index.html' ; return ltrim ( preg_replace ( '/\/\/+/' , '/' , $ result ) , '/' ) ; }
Returns the relative path of a term .
50,308
protected function getTermPermalink ( $ TermRelativePath ) { if ( is_null ( $ TermRelativePath ) ) { return ; } $ result = $ TermRelativePath ; $ basename = basename ( $ TermRelativePath ) ; if ( $ basename === 'index.html' ) { $ result = dirname ( $ TermRelativePath ) ; if ( $ result === '.' ) { $ result = '' ; } } return '/' . $ result ; }
Returns the permalink of a term relative - path - based .
50,309
protected function buildAttributesResolver ( ItemInterface $ templateItem ) { $ resolver = new AttributesResolver ( ) ; $ resolver -> setDefault ( 'taxonomy_attribute' , 'categories' , 'string' ) -> setDefault ( 'permalink' , '/:name' ) -> setDefault ( 'pagination_permalink' , '/page:num' , 'string' ) ; $ attributes = $ templateItem -> getAttributes ( ) ; return $ resolver -> resolve ( $ attributes ) ; }
Build the attribute resolver .
50,310
public function addUse ( ) { if ( false === $ this -> isConfigured ) { $ this -> configure ( ) ; $ this -> isConfigured = true ; } if ( $ this -> referenceCounter < 0 ) { $ this -> referenceCounter = 0 ; } if ( $ this -> referenceCounter === 0 ) { $ this -> setUp ( ) ; } ++ $ this -> referenceCounter ; }
Marks as used the data source . This method increases the internal reference count . When the internal reference count goes from 0 to 1 setUp method is invoked .
50,311
public function retrieveMonth ( $ month ) { if ( ! $ month ) { return 0 ; } $ month = mb_strtolower ( $ month ) ; if ( in_array ( $ month , $ this -> monthList ) ) { $ keys = array_keys ( $ this -> monthList , $ month ) ; return $ keys [ 0 ] + 1 ; } return 0 ; }
Month as integer value 1 .. 12 or 0 on error february = > 2
50,312
public function retrieveDay ( $ day , $ month = null ) { $ day = ( int ) $ day ; if ( $ day < 1 || $ day > 31 ) { return 0 ; } return $ day ; }
Day as integer value 1 .. 31 or 0 on error february = > 2
50,313
protected function asString ( $ number , $ digits = 2 ) { $ number = ( string ) $ number ; $ count = mb_strlen ( $ number ) ; while ( $ count < $ digits ) { $ number = '0' . $ number ; $ count ++ ; } return $ number ; }
Converts integer to x - digit string 1 = > 01 12 = > 12
50,314
public function getStability ( ) { if ( is_null ( $ this -> stability ) === false ) { return $ this -> stability ; } if ( preg_match ( '{^[^,\s]*?@(' . implode ( '|' , array_keys ( BasePackage :: $ stabilities ) ) . ')$}i' , $ this -> getVersion ( ) , $ match ) ) { $ stability = $ match [ 1 ] ; } else { $ stability = VersionParser :: parseStability ( $ this -> getVersion ( ) ) ; } $ this -> stability = VersionParser :: normalizeStability ( $ stability ) ; return $ this -> stability ; }
Returns the package s version stability .
50,315
protected function successMessage ( ConsoleIO $ io , $ theme , $ path ) { $ io -> success ( sprintf ( 'New site with theme "%s" created at "%s" folder' , $ theme , $ path ) ) ; }
Writes the success messages .
50,316
protected function getItemAttributes ( ItemInterface $ item ) { $ result = $ item -> getAttributes ( ) ; $ result [ 'id' ] = $ item -> getId ( ) ; $ result [ 'content' ] = $ item -> getContent ( ) ; $ result [ 'collection' ] = $ item -> getCollection ( ) ; $ result [ 'path' ] = $ item -> getPath ( ItemInterface :: SNAPSHOT_PATH_RELATIVE ) ; return $ result ; }
Gets the attributes of an item .
50,317
public function getPathFilename ( ) { $ path = $ this -> getPath ( ) ; if ( $ this -> isInternal ( ) ) { return $ this -> serverRoot . $ path ; } $ path = $ this -> documentRoot . $ path ; if ( is_dir ( $ path ) === true ) { $ path .= '/index.html' ; } return preg_replace ( '/\/\/+/' , '/' , $ path ) ; }
Gets the path with index . html append .
50,318
public function getMimeType ( ) { $ mimetypeRepo = new PhpRepository ( ) ; $ path = $ this -> getPathFilename ( ) ; return $ mimetypeRepo -> findType ( pathinfo ( $ path , PATHINFO_EXTENSION ) ) ? : 'application/octet-stream' ; }
Gets the Mime Type .
50,319
public function generate ( $ targetDir , \ DateTime $ date , $ title , $ layout , array $ tags = [ ] , array $ categories = [ ] ) { if ( 0 === strlen ( trim ( $ title ) ) ) { throw new \ RuntimeException ( 'Unable to generate the post as the title is empty.' ) ; } if ( file_exists ( $ targetDir ) ) { if ( false === is_dir ( $ targetDir ) ) { throw new \ RuntimeException ( sprintf ( 'Unable to generate the post as the target directory "%s" exists but is a file.' , $ targetDir ) ) ; } if ( false === is_writable ( $ targetDir ) ) { throw new \ RuntimeException ( sprintf ( 'Unable to generate the post as the target directory "%s" is not writable.' , $ targetDir ) ) ; } } $ model = [ 'layout' => $ layout , 'title' => $ title , 'categories' => $ categories , 'tags' => $ tags , ] ; $ this -> cleanFilesAffected ( ) ; $ this -> renderFile ( 'post/post.md.twig' , $ targetDir . '/' . $ this -> getPostFilename ( $ date , $ title ) , $ model ) ; return $ this -> getFilesAffected ( ) ; }
Generates a post .
50,320
public function add ( $ key , $ element ) { if ( $ this -> has ( $ key ) === false ) { $ this -> set ( $ key , $ element ) ; } }
Adds a new element in this collection .
50,321
public function get ( $ key ) { if ( $ this -> has ( $ key ) === false ) { throw new \ RuntimeException ( sprintf ( 'Element with key: "%s" not found.' , $ key ) ) ; } return $ this -> elements [ $ key ] ; }
Gets a element from the collection .
50,322
public function setCommandData ( $ name , $ description = '' , $ help = '' ) { $ this -> commandName = $ name ; $ this -> commandDescription = $ description ; $ this -> commandHelp = $ help ; }
Sets the command s data in case of command plugin .
50,323
public function generate ( ) { $ this -> dirctoryName = $ this -> getPluginDir ( $ this -> name ) ; $ pluginDir = $ this -> targetDir . '/' . $ this -> dirctoryName ; if ( file_exists ( $ pluginDir ) ) { throw new \ RuntimeException ( sprintf ( 'Unable to generate the plugin as the plugin directory "%s" exists.' , $ pluginDir ) ) ; } $ model = [ 'name' => $ this -> name , 'classname' => $ this -> getClassname ( $ this -> name ) , 'namespace' => $ this -> namespace , 'namespace_psr4' => $ this -> getNamespacePsr4 ( $ this -> namespace ) , 'author' => $ this -> author , 'email' => $ this -> email , 'description' => $ this -> description , 'license' => $ this -> license , ] ; $ this -> cleanFilesAffected ( ) ; $ pluginTemplateFile = 'plugin/plugin.php.twig' ; if ( empty ( $ this -> commandName ) === false ) { $ pluginTemplateFile = 'plugin/commandPlugin.php.twig' ; $ model [ 'command_name' ] = $ this -> commandName ; $ model [ 'command_description' ] = $ this -> commandDescription ; $ model [ 'command_help' ] = $ this -> commandHelp ; } $ this -> renderFile ( $ pluginTemplateFile , $ pluginDir . '/' . $ this -> getPluginFilename ( $ this -> name ) , $ model ) ; $ this -> renderFile ( 'plugin/composer.json.twig' , $ pluginDir . '/composer.json' , $ model ) ; $ licenseFile = $ this -> getLicenseFile ( $ this -> license ) ; if ( $ licenseFile ) { $ model = [ 'author' => $ this -> author , ] ; $ this -> renderFile ( $ licenseFile , $ pluginDir . '/LICENSE' , $ model ) ; } return $ this -> getFilesAffected ( ) ; }
Generates a plugin .
50,324
protected function getClassname ( $ name ) { $ result = implode ( ' ' , explode ( '/' , $ name ) ) ; $ result = implode ( ' ' , explode ( '-' , $ result ) ) ; $ result = ucwords ( $ result ) ; $ result = preg_replace ( '/[^\\pL\d]+/u' , '' , $ result ) ; $ result = trim ( $ result , '-' ) ; $ result = iconv ( 'UTF-8' , 'US-ASCII//TRANSLIT' , $ result ) ; $ result = preg_replace ( '/[^-\w]+/' , '' , $ result ) ; return $ result ; }
Gets the classname .
50,325
protected function getLicenseFile ( $ licenseName ) { return isset ( $ this -> licenses [ strtoupper ( $ licenseName ) ] ) ? $ this -> licenses [ strtoupper ( $ licenseName ) ] : '' ; }
Gets the license filename .
50,326
public function addGenerator ( $ name , GeneratorInterface $ generator ) { if ( $ this -> hasGenerator ( $ name ) === true ) { throw new \ RuntimeException ( sprintf ( 'A previous generator exists with the same name: "%s".' , $ name ) ) ; } $ this -> setGenerator ( $ name , $ generator ) ; }
Adds a new generator .
50,327
public function getGenerator ( $ name ) { if ( $ this -> hasGenerator ( $ name ) === false ) { throw new \ RuntimeException ( sprintf ( 'Generator not found: "%s".' , $ name ) ) ; } return $ this -> generators [ $ name ] ; }
Gets a generator .
50,328
public function setDefault ( $ attribute , $ value , $ type = null , $ required = false , $ nullable = false ) { $ this -> defaults [ $ attribute ] = $ value ; if ( empty ( $ type ) === false ) { $ this -> types [ $ attribute ] = $ type ; } if ( $ required === true ) { $ this -> requires [ ] = $ attribute ; } if ( $ nullable === false ) { $ this -> notNullables [ ] = $ attribute ; } return $ this ; }
Sets the default value of a given attribute .
50,329
public function resolve ( array $ attributes ) { $ clone = clone $ this ; $ clone -> resolved = array_replace ( $ clone -> defaults , $ attributes ) ; foreach ( $ clone -> types as $ attribute => $ type ) { if ( function_exists ( $ isFunction = 'is_' . $ type ) === true ) { if ( is_null ( $ clone -> resolved [ $ attribute ] ) === false && $ isFunction ( $ clone -> resolved [ $ attribute ] ) === false ) { throw new AttributeValueException ( sprintf ( 'Invalid type of value. Expected "%s".' , $ type ) , $ attribute ) ; } } } foreach ( $ clone -> notNullables as $ attribute ) { if ( is_null ( $ clone -> resolved [ $ attribute ] ) === true ) { throw new AttributeValueException ( 'Unexpected null value.' , $ attribute ) ; } } foreach ( $ clone -> validators as $ attribute => $ validator ) { if ( is_null ( $ clone -> resolved [ $ attribute ] ) === false && $ validator ( $ clone -> resolved [ $ attribute ] ) === false ) { throw new AttributeValueException ( sprintf ( 'Invalid value.' , $ attribute ) , $ attribute ) ; } } foreach ( $ clone -> requires as $ attribute ) { if ( array_key_exists ( $ attribute , $ attributes ) === false ) { throw new MissingAttributeException ( sprintf ( 'Missing attribute or option "%s".' , $ attribute ) ) ; } } return $ clone -> resolved ; }
Merges options with the default values and validates them . If an attribute is marked as nullable the validate function never will be invoked .
50,330
public function clear ( ) { $ this -> defaults = [ ] ; $ this -> types = [ ] ; $ this -> requires = [ ] ; $ this -> notNullables = [ ] ; return $ this ; }
Remove all attributes .
50,331
public function remove ( $ attributes ) { foreach ( ( array ) $ attributes as $ attribute ) { unset ( $ this -> defaults [ $ attribute ] , $ this -> types [ $ attribute ] , $ this -> requires [ $ attribute ] , $ this -> notNullables [ $ attribute ] ) ; } return $ this ; }
Removes the attributes with the given name .
50,332
public static function validateEmail ( $ email ) { $ email = trim ( $ email ) ; if ( false === filter_var ( $ email , FILTER_VALIDATE_EMAIL ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The Email "%s" is invalid.' , $ email ) ) ; } return $ email ; }
Validator for a Email .
50,333
public function load ( ) { $ this -> initialize ( ) ; foreach ( $ this -> dataSources as $ name => $ dataSource ) { $ dataSource -> load ( ) ; $ this -> processItems ( $ dataSource -> getItems ( ) , $ name ) ; $ this -> processLayouts ( $ dataSource -> getLayouts ( ) , $ name ) ; $ this -> processIncludes ( $ dataSource -> getIncludes ( ) , $ name ) ; } }
Load the items from the registered data sources .
50,334
public function addDataSource ( $ name , AbstractDataSource $ dataSource ) { if ( $ this -> hasDataSource ( $ name ) ) { throw new \ RuntimeException ( sprintf ( 'A previous data source exists with the same name: "%s".' , $ name ) ) ; } $ this -> dataSources [ $ name ] = $ dataSource ; }
Adds a new data source .
50,335
public function getDataSource ( $ name ) { if ( false === $ this -> hasDataSource ( $ name ) ) { throw new \ RuntimeException ( sprintf ( 'Data source: "%s" not found.' , $ name ) ) ; } return $ this -> dataSources [ $ name ] ; }
Gets a data source .
50,336
public function getPackageManager ( $ siteDir , IOInterface $ io ) { $ embeddedComposer = $ this -> getEmbeddedComposer ( $ siteDir , 'composer.json' , 'vendor' ) ; $ embeddedComposer -> processAdditionalAutoloads ( ) ; return new PackageManager ( $ embeddedComposer , $ io ) ; }
Returns an instance of PackageManager . It is configured to read a composer . json file .
50,337
protected function getEmbeddedComposer ( $ siteDir , $ composerFilename , $ vendorDir ) { $ classloader = $ this -> getApplication ( ) -> getClassloader ( ) ; $ builder = new EmbeddedComposerBuilder ( $ classloader , $ siteDir ) ; return $ builder -> setComposerFilename ( $ composerFilename ) -> setVendorDirectory ( $ vendorDir ) -> build ( ) ; }
Returns an EmbeddedComposer instance .
50,338
protected function prepareUrl ( $ url ) { if ( empty ( $ url ) ) { throw new \ RuntimeException ( sprintf ( 'Empty URL at item with id: "%s"' , $ this -> getId ( ) ) ) ; } if ( stripos ( $ url , '://' ) !== false ) { throw new \ RuntimeException ( sprintf ( 'Malformed relative URL at item with id: "%s"' , $ this -> getId ( ) ) ) ; } if ( stripos ( $ url , '/' ) !== 0 ) { throw new \ RuntimeException ( sprintf ( 'Relative URL must start with "/" at item with id: "%s"' , $ this -> getId ( ) ) ) ; } return $ url ; }
Prepare a URL .
50,339
public function build ( ) { $ pm = new PluginManager ( $ this -> eventDispatcher ) ; $ pluginCollection = $ pm -> getPluginCollection ( ) ; if ( file_exists ( $ this -> path ) === false ) { return $ pm ; } $ classnamesFromComposerFile = [ ] ; $ finder = $ this -> buildFinder ( ) ; foreach ( $ finder as $ file ) { if ( $ file -> getFilename ( ) === $ this -> composerFilename ) { $ classes = $ this -> getClassnamesFromComposerFile ( $ file ) ; $ classnamesFromComposerFile = array_merge ( $ classnamesFromComposerFile , $ classes ) ; continue ; } $ classname = $ this -> getClassnameFromPHPFilename ( $ file ) ; include_once $ file -> getRealPath ( ) ; if ( $ this -> hasImplementedPluginInterface ( $ classname ) === false ) { continue ; } $ this -> addPluginToCollection ( $ classname , $ pluginCollection ) ; } foreach ( $ classnamesFromComposerFile as $ classname ) { if ( $ this -> hasImplementedPluginInterface ( $ classname ) === true ) { $ this -> addPluginToCollection ( $ classname , $ pluginCollection ) ; } } return $ pm ; }
Builds the PluginManager with the plugins of a site .
50,340
protected function getClassnamesFromComposerFile ( SplFileInfo $ file ) { $ composerData = $ this -> readComposerFile ( $ file ) ; if ( isset ( $ composerData [ 'extra' ] [ 'spress_class' ] ) === false ) { return [ ] ; } if ( is_string ( $ composerData [ 'extra' ] [ 'spress_class' ] ) === false && is_array ( $ composerData [ 'extra' ] [ 'spress_class' ] ) === false ) { return [ ] ; } return ( array ) $ composerData [ 'extra' ] [ 'spress_class' ] ; }
Extracts the class names from a composer . json file A composer . json file could defines several classes in spress_class property from extra section .
50,341
protected function getPluginMetas ( PluginInterface $ plugin ) { $ metas = $ plugin -> getMetas ( ) ; if ( is_array ( $ metas ) === false ) { $ classname = get_class ( $ plugin ) ; throw new \ RuntimeException ( sprintf ( 'Expected an array at method "getMetas" of the plugin: "%s".' , $ classname ) ) ; } $ metas = $ this -> resolver -> resolve ( $ metas ) ; if ( empty ( $ metas [ 'name' ] ) === true ) { $ metas [ 'name' ] = get_class ( $ plugin ) ; } return $ metas ; }
Gets metas of a plugin .
50,342
protected function hasImplementedPluginInterface ( $ name ) { $ result = false ; if ( class_exists ( $ name ) ) { $ implements = class_implements ( $ name ) ; if ( isset ( $ implements [ 'Yosymfony\\Spress\\Core\\Plugin\\PluginInterface' ] ) ) { $ result = true ; } } return $ result ; }
Checks if the class implements the PluginInterface .
50,343
protected function readComposerFile ( SplFileInfo $ file ) { $ json = $ file -> getContents ( ) ; $ data = json_decode ( $ json , true ) ; return $ data ; }
Reads a composer . json file .
50,344
protected function buildFinder ( ) { $ finder = new Finder ( ) ; $ finder -> files ( ) -> name ( '/(\.php|composer\.json)$/' ) -> in ( $ this -> path ) -> exclude ( $ this -> excludeDirs ) ; return $ finder ; }
Returns a Finder set up for finding both composer . json and php files .
50,345
public function start ( ) { $ this -> initialMessage ( ) ; $ server = new \ Yosymfony \ HttpServer \ HttpServer ( $ this -> requestHandler ) ; $ server -> start ( ) ; }
Run the built - in server .
50,346
protected function render ( $ template , $ model ) { $ twig = $ this -> getTwig ( ) ; return $ twig -> render ( $ template , $ model ) ; }
Render a content using Twig template engine .
50,347
protected function getTwig ( ) { $ options = [ 'cache' => false , 'strict_variables' => true , ] ; $ loader = new \ Twig_Loader_Filesystem ( ) ; $ loader -> setPaths ( $ this -> skeletonDirs ) ; return new \ Twig_Environment ( $ loader , $ options ) ; }
Return an instance of Twig .
50,348
protected function renderFile ( $ template , $ target , $ model ) { if ( ! is_dir ( dirname ( $ target ) ) ) { mkdir ( dirname ( $ target ) , 0777 , true ) ; } $ this -> files [ ] = $ target ; return file_put_contents ( $ target , $ this -> render ( $ template , $ model ) ) ; }
Render a template and result is dumped to a file .
50,349
public function getAttributesFromString ( $ value ) { if ( empty ( $ value ) === true ) { return [ ] ; } $ repository = $ this -> config -> load ( $ value , $ this -> type ) ; return $ repository -> getArray ( ) ; }
Get the attributes of an item from string .
50,350
public function getAttributesFromFrontmatter ( $ value ) { $ found = preg_match ( $ this -> pattern , $ value , $ matches ) ; if ( 1 === $ found ) { return $ this -> getAttributesFromString ( $ matches [ 1 ] ) ; } return [ ] ; }
Get the attributes from the fronmatter of an item . Front - matter block let you specify certain attributes of the page and define new variables that will be available in the content .
50,351
public function findCalendar ( Query $ query , array $ options ) { $ field = $ this -> getConfig ( 'field' ) ; $ year = $ options [ static :: YEAR ] ; $ month = $ options [ static :: MONTH ] ; $ from = new Time ( $ year . '-' . $ month . '-01' ) ; $ lastDayOfMonth = $ from -> daysInMonth ; $ to = new Time ( $ year . '-' . $ month . '-' . $ lastDayOfMonth . ' 23:59:59' ) ; $ conditions = [ $ field . ' >=' => $ from , $ field . ' <=' => $ to ] ; if ( $ this -> getConfig ( 'endField' ) ) { $ endField = $ this -> getConfig ( 'endField' ) ; $ conditions = [ 'OR' => [ [ $ field . ' <=' => $ to , $ endField . ' >' => $ from , ] , $ conditions ] ] ; } $ query -> where ( $ conditions ) ; if ( $ this -> getConfig ( 'scope' ) ) { $ query -> andWhere ( $ this -> getConfig ( 'scope' ) ) ; } return $ query ; }
Custom finder for Calendars field .
50,352
public function parseSite ( array $ attributes , array $ spressAttributes , $ draft = false , $ safe = false , $ timezone = 'UTC' ) { $ this -> attributes = $ attributes ; $ this -> spressAttributes = $ spressAttributes ; $ this -> safe = $ safe ; $ this -> timezone = $ timezone ; $ this -> processDraft = $ draft ; $ this -> reset ( ) ; $ this -> setUp ( ) ; $ this -> initializePlugins ( ) ; $ this -> process ( ) ; $ this -> finish ( ) ; return $ this -> itemCollection -> all ( ) ; }
Parses a site .
50,353
public function setDependencyResolver ( DependencyResolver $ dependencyResolver ) { if ( $ this -> dependencyResolver != null ) { throw new \ LogicException ( 'There is an instance of DependencyManager class in class ContentManager.' ) ; } $ this -> dependencyResolver = $ dependencyResolver ; }
Sets the dependency resolver .
50,354
public function addLayout ( $ id , $ content , array $ attributes = [ ] ) { $ namespaceLayoutId = $ this -> getLayoutNameWithNamespace ( $ id ) ; $ this -> layouts [ $ namespaceLayoutId ] = [ $ id , $ content , $ attributes ] ; }
Adds a new layout .
50,355
public function addTwigFilter ( $ name , callable $ filter , array $ options = [ ] ) { $ twigFilter = new \ Twig_SimpleFilter ( $ name , $ filter , $ options ) ; $ this -> twig -> addFilter ( $ twigFilter ) ; }
Adds a new Twig filter .
50,356
public function addTwigFunction ( $ name , callable $ function , array $ options = [ ] ) { $ twigfunction = new \ Twig_SimpleFunction ( $ name , $ function , $ options ) ; $ this -> twig -> addFunction ( $ twigfunction ) ; }
Adds a new Twig function .
50,357
protected function getLayoutAttributeWithNamespace ( array $ attributes , $ contentName ) { if ( isset ( $ attributes [ 'layout' ] ) === false ) { return '' ; } if ( is_string ( $ attributes [ 'layout' ] ) === false ) { throw new AttributeValueException ( 'Invalid value. Expected string.' , 'layout' , $ contentName ) ; } if ( strlen ( $ attributes [ 'layout' ] ) == 0 ) { throw new AttributeValueException ( 'Invalid value. Expected a non-empty string.' , 'layout' , $ contentName ) ; } return $ this -> getLayoutNameWithNamespace ( $ attributes [ 'layout' ] ) ; }
Returns the value of layout attribute .
50,358
public function registerCommandPlugins ( ) { $ spress = $ this -> getSpress ( ) ; try { $ pm = $ spress [ 'spress.plugin.pluginManager' ] ; $ commandBuilder = new ConsoleCommandBuilder ( $ pm ) ; $ consoleCommandFromPlugins = $ commandBuilder -> buildCommands ( ) ; foreach ( $ consoleCommandFromPlugins as $ consoleCommand ) { $ this -> add ( $ consoleCommand ) ; } } catch ( \ Exception $ e ) { } }
Registers the command plugins present in the current directory .
50,359
public function registerStandardCommands ( ) { $ welcomeCommand = new WelcomeCommand ( ) ; $ this -> add ( $ welcomeCommand ) ; $ this -> add ( new NewPluginCommand ( ) ) ; $ this -> add ( new NewPostCommand ( ) ) ; $ this -> add ( new NewSiteCommand ( ) ) ; $ this -> add ( new NewThemeCommand ( ) ) ; $ this -> add ( new SelfUpdateCommand ( ) ) ; $ this -> add ( new SiteBuildCommand ( ) ) ; $ this -> add ( new UpdatePluginCommand ( ) ) ; $ this -> add ( new AddPluginCommand ( ) ) ; $ this -> add ( new RemovePluginCommand ( ) ) ; $ this -> setDefaultCommand ( $ welcomeCommand -> getName ( ) ) ; }
Registers the standard commands of Spress .
50,360
public function addArgument ( $ name , $ mode = null , $ description = '' , $ default = null ) { if ( null === $ mode ) { $ mode = self :: OPTIONAL ; } elseif ( ! is_int ( $ mode ) || $ mode > 7 || $ mode < 1 ) { throw new \ InvalidArgumentException ( sprintf ( 'Argument mode "%s" is not valid.' , $ mode ) ) ; } $ this -> arguments [ ] = [ $ name , $ mode , $ description , $ default ] ; }
Adds a new command argument .
50,361
public function addOption ( $ name , $ shortcut = null , $ mode = null , $ description = '' , $ default = null ) { if ( empty ( $ name ) ) { throw new \ InvalidArgumentException ( 'An option name cannot be empty.' ) ; } if ( null === $ mode ) { $ mode = self :: VALUE_NONE ; } elseif ( ! is_int ( $ mode ) || $ mode > 15 || $ mode < 1 ) { throw new \ InvalidArgumentException ( sprintf ( 'Option mode "%s" is not valid.' , $ mode ) ) ; } $ this -> options [ ] = [ $ name , $ shortcut , $ mode , $ description , $ default ] ; }
Adds a new command option .
50,362
public function callInitialize ( ) { foreach ( $ this -> pluginCollection as $ plugin ) { $ subscriber = new EventSubscriber ( ) ; $ plugin -> initialize ( $ subscriber ) ; $ this -> eventSubscriberPlugins [ ] = [ $ plugin , $ subscriber ] ; $ this -> addListeners ( $ plugin , $ subscriber ) ; } }
Invokes initialize method for each plugin registered .
50,363
public function tearDown ( ) { foreach ( $ this -> eventSubscriberPlugins as list ( $ plugin , $ eventSubscriber ) ) { $ this -> removeListeners ( $ plugin , $ eventSubscriber ) ; } }
Releases resources like event listeners .
50,364
public function buildFromConfigArray ( array $ config ) { $ dsm = new DataSourceManager ( ) ; foreach ( $ config as $ dataSourceName => $ data ) { if ( false === isset ( $ data [ 'class' ] ) ) { throw new \ RuntimeException ( sprintf ( 'Expected param "class" at the configuration of the data source: "%s".' , $ dataSourceName ) ) ; } $ classname = $ data [ 'class' ] ; $ arguments = true === isset ( $ data [ 'arguments' ] ) ? $ data [ 'arguments' ] : [ ] ; if ( count ( $ this -> parameterKeys ) > 0 && count ( $ arguments ) > 0 ) { $ arguments = $ this -> resolveArgumentsParameters ( $ arguments ) ; } if ( false === class_exists ( $ classname ) ) { throw new \ RuntimeException ( sprintf ( 'Data source "%s" class not found: "%s".' , $ dataSourceName , $ classname ) ) ; } $ ds = new $ classname ( $ arguments ) ; $ dsm -> addDataSource ( $ dataSourceName , $ ds ) ; } return $ dsm ; }
Build a data source manager with data sources loaded from config array .
50,365
protected function resolveArgumentsParameters ( array $ arguments ) { foreach ( $ arguments as $ argument => & $ value ) { if ( is_string ( $ value ) === false || preg_match ( '/%[\S_\-]+%/' , $ value , $ matches ) === false ) { continue ; } $ name = $ matches [ 0 ] ; if ( array_key_exists ( $ name , $ this -> parameters ) === false ) { continue ; } if ( is_string ( $ this -> parameters [ $ name ] ) ) { $ value = str_replace ( $ name , $ this -> parameters [ $ name ] , ( string ) $ value ) ; continue ; } $ value = $ this -> parameters [ $ name ] ; } return $ arguments ; }
Resolve parameters in arguments .
50,366
public function paginate ( $ maxPerPage , $ initialPage = 1 , $ key = null ) { $ result = [ ] ; $ page = $ initialPage ; $ array = $ this -> array ; if ( $ maxPerPage <= 0 ) { return $ result ; } if ( is_null ( $ key ) === false ) { $ array = $ this -> get ( $ key ) ; } $ arrCount = count ( $ array ) ; for ( $ offset = 0 ; $ offset < $ arrCount ; ) { $ slice = array_slice ( $ array , $ offset , $ maxPerPage , true ) ; $ result [ $ page ] = $ slice ; ++ $ page ; $ offset += count ( $ slice ) ; } return $ result ; }
Paginates the array .
50,367
public function remove ( $ key ) { $ array = & $ this -> array ; if ( is_null ( $ key ) ) { return $ array ; } $ keys = explode ( '.' , $ this -> escapedDotKeyToUnderscore ( $ key ) ) ; while ( count ( $ keys ) > 1 ) { $ key = $ this -> underscoreDotKeyToDot ( array_shift ( $ keys ) ) ; if ( isset ( $ array [ $ key ] ) === false || is_array ( $ array [ $ key ] ) === false ) { $ array [ $ key ] = [ ] ; } $ array = & $ array [ $ key ] ; } unset ( $ array [ $ this -> underscoreDotKeyToDot ( array_shift ( $ keys ) ) ] ) ; return $ this -> array ; }
Removes an item using dot notation .
50,368
public function sortBy ( callable $ callback , $ key = null , $ options = SORT_REGULAR , $ isDescending = false ) { $ elements = [ ] ; $ sourceElements = is_null ( $ key ) === true ? $ this -> array : $ this -> get ( $ key ) ; foreach ( $ sourceElements as $ key => $ value ) { $ elements [ $ key ] = $ callback ( $ key , $ value ) ; } $ isDescending ? arsort ( $ elements , $ options ) : asort ( $ elements , $ options ) ; foreach ( array_keys ( $ elements ) as $ key ) { $ elements [ $ key ] = $ sourceElements [ $ key ] ; } return $ elements ; }
Sort the array sing the given callback .
50,369
public function where ( callable $ filter ) { $ filtered = [ ] ; foreach ( $ this -> array as $ key => $ value ) { if ( $ filter ( $ key , $ value ) === true ) { $ filtered [ $ key ] = $ value ; } } return $ filtered ; }
Filter using the given callback function .
50,370
public function slug ( $ separator = '-' ) { $ str = $ this -> toAscii ( ) ; $ flip = $ separator == '-' ? '_' : '-' ; $ str = str_replace ( '.' , $ separator , $ str ) ; $ str = preg_replace ( '![' . preg_quote ( $ flip ) . ']+!u' , $ separator , $ str ) ; $ str = preg_replace ( '![^' . preg_quote ( $ separator ) . '\pL\pN\s]+!u' , '' , mb_strtolower ( $ str ) ) ; $ str = preg_replace ( '![' . preg_quote ( $ separator ) . '\s]+!u' , $ separator , $ str ) ; return trim ( $ str , $ separator ) ; }
Generate a URL friendly slug .
50,371
public function deletePrefix ( $ prefix ) { if ( $ this -> startWith ( $ prefix ) === true ) { return substr ( $ this -> str , strlen ( $ prefix ) ) ; } return $ this -> str ; }
Deletes a prefix of the string .
50,372
public function deleteSufix ( $ sufix ) { if ( $ this -> endWith ( $ sufix ) === true ) { return substr ( $ this -> str , 0 , - strlen ( $ sufix ) ) ; } return $ this -> str ; }
Deletes a sufix of the string .
50,373
public function getCollectionForItem ( ItemInterface $ item ) { foreach ( $ this -> colectionItemCollection as $ name => $ collection ) { $ itemPath = $ item -> getPath ( ItemInterface :: SNAPSHOT_PATH_RELATIVE ) . '/' ; $ collectionPath = $ collection -> getPath ( ) . '/' ; if ( strpos ( $ itemPath , $ collectionPath ) === 0 ) { return $ collection ; } } return $ this -> colectionItemCollection -> get ( 'pages' ) ; }
Collection matching of a item .
50,374
public function add ( $ name , ItemInterface $ item ) { if ( isset ( $ this -> relationships [ $ name ] ) === false ) { $ this -> relationships [ $ name ] = [ ] ; } unset ( $ this -> relationships [ $ name ] [ $ item -> getId ( ) ] ) ; $ this -> relationships [ $ name ] [ $ item -> getId ( ) ] = $ item ; }
Adds a relationship .
50,375
public function remove ( $ name , ItemInterface $ item ) { unset ( $ this -> relationships [ $ name ] [ $ item -> getId ( ) ] ) ; if ( count ( $ this -> relationships [ $ name ] ) === 0 ) { unset ( $ this -> relationships [ $ name ] ) ; } }
Removes a relationship from the collection .
50,376
public function addItem ( ItemInterface $ item ) { if ( $ this -> hasItem ( $ item -> getId ( ) ) === true ) { throw new \ RuntimeException ( sprintf ( 'A previous item exists with the same id: "%s".' , $ item -> getId ( ) ) ) ; } $ this -> items [ $ item -> getId ( ) ] = $ item ; }
Adds a new item .
50,377
public function addLayout ( ItemInterface $ item ) { if ( $ this -> hasLayout ( $ item -> getId ( ) ) === true ) { throw new \ RuntimeException ( sprintf ( 'A previous layout item exists with the same id: "%s".' , $ item -> getId ( ) ) ) ; } $ this -> layouts [ $ item -> getId ( ) ] = $ item ; }
Adds a new layout item .
50,378
public function addInclude ( ItemInterface $ item ) { if ( $ this -> hasInclude ( $ item -> getId ( ) ) === true ) { throw new \ RuntimeException ( sprintf ( 'A previous include item exists with the same id: "%s".' , $ item -> getId ( ) ) ) ; } $ this -> includes [ $ item -> getId ( ) ] = $ item ; }
Adds a new include item .
50,379
private function registerServiceProviders ( ) { $ this -> app -> register ( ArboryTranslationServiceProvider :: class ) ; $ this -> app -> register ( TranslatableServiceProvider :: class ) ; $ this -> app -> register ( ArboryFileServiceProvider :: class ) ; $ this -> app -> register ( ArboryAuthServiceProvider :: class ) ; $ this -> app -> register ( GlideImageServiceProvider :: class ) ; $ this -> app -> register ( AssetServiceProvider :: class ) ; $ this -> app -> register ( SettingsServiceProvider :: class ) ; $ this -> app -> register ( ExcelServiceProvider :: class ) ; $ this -> app -> register ( FileManagerServiceProvider :: class ) ; }
Register related service providers
50,380
private function registerAliases ( ) { $ aliasLoader = AliasLoader :: getInstance ( ) ; $ aliasLoader -> alias ( 'Activation' , \ Cartalyst \ Sentinel \ Laravel \ Facades \ Activation :: class ) ; $ aliasLoader -> alias ( 'Reminder' , \ Cartalyst \ Sentinel \ Laravel \ Facades \ Reminder :: class ) ; $ aliasLoader -> alias ( 'Sentinel' , \ Cartalyst \ Sentinel \ Laravel \ Facades \ Sentinel :: class ) ; $ aliasLoader -> alias ( 'GlideImage' , \ Roboc \ Glide \ Support \ Facades \ GlideImage :: class ) ; $ aliasLoader -> alias ( 'Excel' , \ Maatwebsite \ Excel \ Facades \ Excel :: class ) ; }
Register related aliases
50,381
private function registerRoutesAndMiddlewares ( ) { $ router = $ this -> app [ 'router' ] ; $ router -> middlewareGroup ( 'admin' , [ \ App \ Http \ Middleware \ EncryptCookies :: class , \ Illuminate \ Cookie \ Middleware \ AddQueuedCookiesToResponse :: class , \ Illuminate \ Session \ Middleware \ StartSession :: class , \ Illuminate \ View \ Middleware \ ShareErrorsFromSession :: class , \ App \ Http \ Middleware \ VerifyCsrfToken :: class , \ Illuminate \ Routing \ Middleware \ SubstituteBindings :: class , ArboryAdminHasAllowedIpMiddleware :: class ] ) ; $ router -> aliasMiddleware ( 'arbory.admin_auth' , ArboryAdminAuthMiddleware :: class ) ; $ router -> aliasMiddleware ( 'arbory.admin_module_access' , ArboryAdminModuleAccessMiddleware :: class ) ; $ router -> aliasMiddleware ( 'arbory.admin_quest' , ArboryAdminGuestMiddleware :: class ) ; $ router -> aliasMiddleware ( 'arbory.admin_in_role' , ArboryAdminInRoleMiddleware :: class ) ; $ router -> aliasMiddleware ( 'arbory.admin_has_access' , ArboryAdminHasAccessMiddleware :: class ) ; $ router -> aliasMiddleware ( 'arbory.route_redirect' , ArboryRouteRedirectMiddleware :: class ) ; $ router -> aliasMiddleware ( 'arbory.admin_has_allowed_ip' , ArboryAdminHasAllowedIpMiddleware :: class ) ; $ this -> app -> booted ( function ( $ app ) { $ app [ Kernel :: class ] -> prependMiddleware ( ArboryRouteRedirectMiddleware :: class ) ; } ) ; $ this -> registerAdminRoutes ( ) ; $ this -> registerAppRoutes ( ) ; }
Load admin routes and register middleware
50,382
private function registerCommands ( ) { $ commands = [ 'arbory.seed' => SeedCommand :: class , 'arbory.install' => InstallCommand :: class , 'arbory.generator' => GeneratorCommand :: class , 'arbory.generate' => GenerateCommand :: class ] ; foreach ( $ commands as $ containerKey => $ commandClass ) { $ this -> registerCommand ( $ containerKey , $ commandClass ) ; } }
Register Arbory commands
50,383
private function registerModuleRegistry ( ) { $ this -> app -> singleton ( 'arbory' , function ( ) { return new Admin ( $ this -> app [ 'sentinel' ] , new Menu ( ) , new AssetPipeline ( ) ) ; } ) ; $ this -> app -> singleton ( Admin :: class , function ( ) { return $ this -> app [ 'arbory' ] ; } ) ; }
Register Arbory module registry
50,384
private function registerFields ( ) { $ this -> app -> singleton ( FieldTypeRegistry :: class , function ( Application $ app ) { $ fieldTypeRegistry = new FieldTypeRegistry ( ) ; $ fieldTypeRegistry -> registerByType ( 'integer' , Hidden :: class , 'int' ) ; $ fieldTypeRegistry -> registerByType ( 'string' , Text :: class , 'string' ) ; $ fieldTypeRegistry -> registerByType ( 'text' , Textarea :: class , 'string' ) ; $ fieldTypeRegistry -> registerByType ( 'longtext' , Richtext :: class , 'string' ) ; $ fieldTypeRegistry -> registerByType ( 'datetime' , DateTime :: class , 'string' ) ; $ fieldTypeRegistry -> registerByType ( 'boolean' , Checkbox :: class , 'bool' ) ; $ fieldTypeRegistry -> registerByRelation ( 'file' , ArboryFile :: class ) ; $ fieldTypeRegistry -> registerByRelation ( 'image' , ArboryImage :: class ) ; $ fieldTypeRegistry -> registerByRelation ( 'link' , Link :: class ) ; return $ fieldTypeRegistry ; } ) ; }
Register Arbory fields
50,385
private function registerGeneratorStubs ( ) { $ this -> app -> singleton ( StubRegistry :: class , function ( Application $ app ) { $ stubRegistry = new StubRegistry ( ) ; $ stubRegistry -> registerStubs ( $ app [ Filesystem :: class ] , base_path ( 'vendor/arbory/arbory/stubs' ) ) ; return $ stubRegistry ; } ) ; }
Register stubs used by generators
50,386
public static function filter ( $ html , array $ config = null , $ spec = null ) { require_once __DIR__ . '/htmLawed/htmLawed.php' ; if ( $ config === null ) { $ config = self :: $ defaultConfig ; } if ( isset ( $ config [ 'spec' ] ) && ! $ spec ) { $ spec = $ config [ 'spec' ] ; } if ( $ spec === null ) { $ spec = static :: $ defaultSpec ; } return htmLawed ( $ html , $ config , $ spec ) ; }
Filters a string of html with the htmLawed library .
50,387
public static function filterRSS ( $ html ) { $ config = array ( 'anti_link_spam' => [ '`.`' , '' ] , 'comment' => 1 , 'cdata' => 3 , 'css_expression' => 1 , 'deny_attribute' => 'on*,style,class' , 'elements' => '*-applet-form-input-textarea-iframe-script-style-object-embed-comment-link-listing-meta-noscript-plaintext-xmp' , 'keep_bad' => 0 , 'schemes' => 'classid:clsid; href: aim, feed, file, ftp, gopher, http, https, irc, mailto, news, nntp, sftp, ssh, telnet; style: nil; *:file, http, https' , 'valid_xhtml' => 1 , 'balance' => 1 ) ; $ spec = static :: $ defaultSpec ; $ result = static :: filter ( $ html , $ config , $ spec ) ; return $ result ; }
Filter a string of html so that it can be put into an rss feed .
50,388
public function clear ( ) { $ this -> session -> remove ( $ this -> getSessionKey ( ) ) ; $ this -> session -> remove ( $ this -> getSessionExtraKey ( ) ) ; $ this -> session -> remove ( $ this -> getSessionTargetPathKey ( ) ) ; }
Clear services management session variables .
50,389
public function getdiff ( $ struct1 , $ struct2 , $ slashtoobject = false ) { if ( ! $ this -> studyType ( $ struct1 , $ problem ) || ! $ this -> studyType ( $ struct2 , $ problem ) ) { return $ problem ; } $ this -> clockStart ( ) ; $ structpath1_array = array ( ) ; $ structpath2_array = array ( ) ; $ this -> structPathArray ( $ struct1 , $ structpath1_array , "" ) ; $ this -> structPathArray ( $ struct2 , $ structpath2_array , "" ) ; $ deltadiff_array = $ this -> structPathArrayDiff ( $ structpath1_array , $ structpath2_array , $ slashtoobject ) ; if ( $ this -> config [ "debug" ] ) { $ deltadiff_array [ "time" ] = $ this -> clockMark ( ) ; } return $ this -> returnTypeConvert ( $ deltadiff_array ) ; }
Returns the difference between two structures
50,390
public function parse ( $ token ) { $ parts = explode ( '.' , $ token ) ; if ( count ( $ parts ) !== 3 ) { throw new InvalidArgumentException ( 'Token is invalid' ) ; } $ this -> token = $ token ; $ this -> header = json_decode ( base64_decode ( $ parts [ 0 ] ) , true ) ; $ this -> payload = json_decode ( base64_decode ( $ parts [ 1 ] ) , true ) ; $ this -> signature = $ parts [ 2 ] ; }
Parse a Token
50,391
public function findFrontPages ( array $ slugs = [ ] , $ host = null , $ locale = null ) { $ qb = $ this -> createQueryBuilder ( 'page' ) -> where ( 'page.enabled = :enabled' ) -> leftJoin ( 'page.category' , 'category' ) -> andWhere ( 'page.category is null OR category.enabled = :enabled' ) -> setParameter ( 'enabled' , true ) ; $ searchForHomepage = 0 === count ( $ slugs ) ; if ( true === $ searchForHomepage ) { $ qb -> andWhere ( 'page.homepage = :homepage' ) -> setParameter ( 'homepage' , true ) -> setMaxResults ( 1 ) ; } elseif ( 1 === count ( $ slugs ) ) { $ qb -> andWhere ( 'page.slug = :slug' ) -> setParameter ( 'slug' , reset ( $ slugs ) ) -> setMaxResults ( 1 ) ; } else { $ qb -> andWhere ( 'page.slug IN ( :slugs )' ) -> setParameter ( 'slugs' , $ slugs ) ; } $ hostWhere = 'page.host IS NULL' ; if ( null !== $ host ) { $ hostWhere .= ' OR page.host = :host' ; $ qb -> setParameter ( 'host' , $ host ) ; $ qb -> addOrderBy ( 'page.host' , 'asc' ) ; } $ qb -> andWhere ( $ hostWhere ) ; $ localeWhere = 'page.locale IS NULL' ; if ( null !== $ locale ) { $ localeWhere .= ' OR page.locale = :locale' ; $ qb -> setParameter ( 'locale' , $ locale ) ; $ qb -> addOrderBy ( 'page.locale' , 'asc' ) ; } $ qb -> andWhere ( $ localeWhere ) ; $ qb -> orderBy ( 'page.host' , 'asc' ) -> addOrderBy ( 'page.locale' , 'asc' ) ; $ results = $ qb -> getQuery ( ) -> useResultCache ( $ this -> cacheEnabled , $ this -> cacheTtl ) -> getResult ( ) ; if ( 0 === count ( $ results ) ) { return $ results ; } if ( true === $ searchForHomepage && count ( $ results ) > 0 ) { reset ( $ results ) ; $ results = [ $ results [ 0 ] ] ; } $ resultsSortedBySlug = [ ] ; foreach ( $ results as $ page ) { $ resultsSortedBySlug [ $ page -> getSlug ( ) ] = $ page ; } $ pages = $ resultsSortedBySlug ; if ( count ( $ slugs ) > 0 ) { $ pages = [ ] ; foreach ( $ slugs as $ value ) { if ( ! array_key_exists ( $ value , $ resultsSortedBySlug ) ) { return [ ] ; } $ pages [ $ value ] = $ resultsSortedBySlug [ $ value ] ; } } return $ pages ; }
Will search for pages to show in front depending on the arguments . If slugs are defined there s no problem in looking for nulled host or locale because slugs are unique so it does not .
50,392
public function make ( array $ config ) : Client { $ config = $ this -> getConfig ( $ config ) ; return $ this -> getClient ( $ config ) ; }
Make a new gitlab client .
50,393
protected function getClient ( array $ config ) : Client { $ client = Client :: create ( $ config [ 'url' ] ) ; $ client -> authenticate ( $ config [ 'token' ] , array_get ( $ config , 'method' , Client :: AUTH_URL_TOKEN ) , array_get ( $ config , 'sudo' , null ) ) ; return $ client ; }
Get the main client .
50,394
protected function getPages ( array $ slugsArray = [ ] ) { $ pages = $ this -> get ( 'orbitale_cms.page_repository' ) -> findFrontPages ( $ slugsArray , $ this -> request -> getHost ( ) , $ this -> request -> getLocale ( ) ) ; if ( ! count ( $ pages ) || ( count ( $ slugsArray ) && count ( $ pages ) !== count ( $ slugsArray ) ) ) { throw $ this -> createNotFoundException ( count ( $ slugsArray ) ? 'Page not found' : 'No homepage has been configured. Please check your existing pages or create a homepage in your application.' ) ; } return $ pages ; }
Retrieves the page list based on slugs . Also checks the hierarchy of the different pages .
50,395
protected function getCurrentPage ( array $ pages , array $ slugsArray ) : Page { if ( count ( $ pages ) === count ( $ slugsArray ) ) { $ currentPage = $ this -> getFinalTreeElement ( $ slugsArray , $ pages ) ; } else { $ currentPage = current ( $ pages ) ; } return $ currentPage ; }
Retrieves the current page based on page list and entered slugs .
50,396
public function fetch ( $ id ) { if ( ! file_exists ( $ this -> filename ( $ id ) ) ) { return false ; } $ filedata = file_get_contents ( $ this -> filename ( $ id ) ) ; $ data = json_decode ( $ filedata , true ) ; if ( $ data [ 'ttl' ] !== null ) { if ( ( $ data [ 'time' ] + $ data [ 'ttl' ] ) < time ( ) ) { return false ; } } return $ data [ 'data' ] ; }
Fetches an entry from the cache or returns false if not exists .
50,397
public function append ( Response $ xResponse ) { if ( ! $ this -> xResponse ) { $ this -> xResponse = $ xResponse ; } elseif ( get_class ( $ this -> xResponse ) == get_class ( $ xResponse ) ) { if ( $ this -> xResponse != $ xResponse ) { $ this -> xResponse -> appendResponse ( $ xResponse ) ; } } else { $ this -> debug ( $ this -> trans ( 'errors.mismatch.types' , array ( 'class' => get_class ( $ xResponse ) ) ) ) ; } }
Append one response object onto the end of another
50,398
public function printDebug ( ) { if ( ( $ this -> xResponse ) ) { foreach ( $ this -> aDebugMessages as $ sMessage ) { $ this -> xResponse -> debug ( $ sMessage ) ; } $ this -> aDebugMessages = [ ] ; } }
Prints the debug messages into the current response object
50,399
private function getClassOptions ( $ sClassName , array $ aDirectoryOptions , array $ aDefaultOptions = [ ] ) { $ aOptions = $ aDefaultOptions ; if ( key_exists ( 'separator' , $ aDirectoryOptions ) ) { $ aOptions [ 'separator' ] = $ aDirectoryOptions [ 'separator' ] ; } if ( key_exists ( 'protected' , $ aDirectoryOptions ) ) { $ aOptions [ 'protected' ] = $ aDirectoryOptions [ 'protected' ] ; } if ( key_exists ( '*' , $ aDirectoryOptions ) ) { $ aOptions = array_merge ( $ aOptions , $ aDirectoryOptions [ '*' ] ) ; } if ( key_exists ( $ sClassName , $ aDirectoryOptions ) ) { $ aOptions = array_merge ( $ aOptions , $ aDirectoryOptions [ $ sClassName ] ) ; } return $ aOptions ; }
Get a given class options from specified directory options