idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
52,500
public function onceUsingId ( $ id ) { $ acct = $ this -> auth -> retrieveById ( $ id ) ; if ( ! is_null ( $ acct ) ) { $ this -> setAcct ( $ acct ) ; return true ; } return false ; }
Log the given acct ID into the application without sessions or cookies .
52,501
public function logout ( ) { $ acct = $ this -> acct ( ) ; $ this -> clearAcctDataFromStorage ( ) ; if ( ! is_null ( $ this -> acct ) ) $ this -> refreshRememberToken ( $ acct ) ; Hooks :: trigger ( 'acct.logout' , compact ( 'acct' ) ) ; $ this -> acct = null ; $ this -> loggedOut = true ; }
Log the acct out of the application .
52,502
protected function clearAcctDataFromStorage ( ) { $ this -> session -> remove ( $ this -> getName ( ) ) ; if ( ! is_null ( $ this -> getRecaller ( ) ) ) { $ recaller = $ this -> getRecallerName ( ) ; $ this -> getCookieJar ( ) -> queue ( $ this -> getCookieJar ( ) -> forget ( $ recaller ) ) ; } }
Remove the acct data from the session and cookies .
52,503
protected function refreshRememberToken ( Account $ acct ) { $ acct -> setRememberToken ( $ token = Str :: random ( 60 ) ) ; $ this -> auth -> updateRememberToken ( $ acct , $ token ) ; }
Refresh the remember me token for the acct .
52,504
public function setAcct ( Account $ acct ) { $ this -> acct = $ acct ; $ this -> loggedOut = false ; return $ this ; }
Set the current acct .
52,505
protected function transform ( $ middleware ) { if ( is_string ( $ middleware ) ) { return $ this -> container -> get ( $ middleware ) ; } if ( is_callable ( $ middleware ) ) { return new ClosureMiddleware ( $ middleware ) ; } return $ middleware ; }
Transforms the specified input into a middleware .
52,506
protected function resolve ( $ index ) { if ( ! isset ( $ this -> stack [ $ index ] ) ) { return new ErrorHandler ; } $ next = $ this -> resolve ( $ index + 1 ) ; $ item = $ this -> stack [ ( integer ) $ index ] ; return new NextHandler ( $ item , $ next ) ; }
Resolves the whole stack through its index .
52,507
static function reindent ( $ source , $ indent = '' , $ tabs_to_spaces = 4 , $ ignore_zero_indent = true ) { if ( $ tabs_to_spaces !== null ) { $ source = str_replace ( "\t" , str_repeat ( ' ' , $ tabs_to_spaces ) , $ source ) ; } $ lines = explode ( "\n" , $ source ) ; $ min_length = null ; foreach ( $ lines as $ line...
Uniforms indentation . Useful when printing .
52,508
public static function make ( string $ path , int $ ifExists = Directory :: MAKE_DIRECTORY_EXISTS_THROW_EXCEPTION ) : Directory { $ exists = Directory :: exists ( $ path ) ; if ( $ exists ) { if ( $ ifExists === Directory :: MAKE_DIRECTORY_EXISTS_OVERWRITE ) { unlink ( $ path ) ; } else if ( $ ifExists === Directory ::...
Makes a directory .
52,509
public function fileExists ( string $ name ) { if ( ! $ this -> _isLoaded ) { $ this -> load ( ) ; } return in_array ( $ name , $ this -> _files ) ; }
Checks if a file exists in this directory .
52,510
public function getFile ( string $ name , int $ ifNotExists = Directory :: GET_FILE_NOT_EXISTS_THROW_EXCEPTION ) : File { $ path = $ this -> getPath ( ) . DIRECTORY_SEPARATOR . $ name ; if ( $ this -> fileExists ( $ name ) ) { return new File ( $ path ) ; } if ( $ ifNotExists === Directory :: GET_FILE_NOT_EXISTS_CREATE...
Returns a file from the directory .
52,511
public function getFiles ( ) : array { if ( ! $ this -> _isLoaded ) { $ this -> load ( ) ; } return array_map ( function ( $ file ) { return new File ( $ this -> getPath ( ) . DIRECTORY_SEPARATOR . $ file ) ; } , $ this -> _files ) ; }
Returns an array with all files of the directory .
52,512
public function directoryExists ( string $ name ) { if ( ! $ this -> _isLoaded ) { $ this -> load ( ) ; } return in_array ( $ name , $ this -> _directories ) ; }
Checks if a directory exists in this directory .
52,513
public function getDirectory ( string $ name , int $ ifNotExists = Directory :: GET_DIRECTORY_NOT_EXISTS_THROW_EXCEPTION ) : Directory { $ path = $ this -> getPath ( ) . DIRECTORY_SEPARATOR . $ name ; if ( $ this -> directoryExists ( $ name ) ) { return new Directory ( $ path ) ; } if ( $ ifNotExists === Directory :: G...
Returns a directory from the directory .
52,514
public function getDirectories ( ) : array { if ( ! $ this -> _isLoaded ) { $ this -> load ( ) ; } return array_map ( function ( $ directory ) { return new Directory ( $ this -> getPath ( ) . DIRECTORY_SEPARATOR . $ directory ) ; } , $ this -> _directories ) ; }
Returns an array with all directories of the directory .
52,515
public function load ( ) { $ files = scandir ( $ this -> getPath ( ) ) ; foreach ( $ files as $ file ) { if ( $ file === "." || $ file === ".." ) { continue ; } if ( is_file ( $ this -> getPath ( ) . $ file ) ) { $ this -> _files [ $ file ] = $ file ; } else if ( is_dir ( $ this -> getPath ( ) . $ file ) ) { $ this -> ...
Loads directories and files .
52,516
public function setLocation ( string $ location ) { $ dir = Directory :: make ( $ location , Directory :: MAKE_DIRECTORY_EXISTS_OPEN ) ; $ old = $ this -> getPath ( ) ; $ new = $ dir -> getPath ( ) ; if ( rename ( $ old , $ new ) ) { $ this -> _location = $ dir -> getPath ( ) ; } }
Moves the file to the specified location .
52,517
public function setPath ( string $ path ) { $ info = pathinfo ( $ path ) ; $ this -> setLocation ( $ info [ "dirname" ] ?? "" ) ; $ this -> setName ( $ info [ "filename" ] ?? "" ) ; }
Sets new file location name and extension .
52,518
protected function createIPCSegment ( ) { $ this -> fileIPC1 = '/tmp/' . mt_rand ( ) . md5 ( $ this -> getName ( ) ) . '.shm' ; touch ( $ this -> fileIPC1 ) ; $ shm_key = ftok ( $ this -> fileIPC1 , 't' ) ; if ( $ shm_key === - 1 ) { throw new Exception ( 'Fatal exception creating SHM segment (ftok)' ) ; } $ this -> in...
Create IPC segment
52,519
protected function createIPCSemaphore ( ) { $ this -> fileIPC2 = '/tmp/' . mt_rand ( ) . md5 ( $ this -> getName ( ) ) . '.sem' ; touch ( $ this -> fileIPC2 ) ; $ sem_key = ftok ( $ this -> fileIPC2 , 't' ) ; if ( $ sem_key === - 1 ) { throw new Exception ( 'Fatal exception creating semaphore (ftok)' ) ; } $ this -> in...
Create IPC semaphore
52,520
protected function writeToIPCSegment ( ) { if ( shmop_read ( $ this -> internalSemaphoreKey , 1 , 1 ) === 1 ) { return ; } $ serialized_IPC_array = serialize ( $ this -> internalIPCArray ) ; $ shm_bytes_written = shmop_write ( $ this -> internalIPCKey , $ serialized_IPC_array , 0 ) ; if ( $ shm_bytes_written !== strlen...
Write to IPC segment
52,521
protected function readFromIPCSegment ( ) { $ serialized_IPC_array = shmop_read ( $ this -> internalIPCKey , 0 , shmop_size ( $ this -> internalIPCKey ) ) ; if ( ! $ serialized_IPC_array ) { throw new Exception ( 'Fatal exception reading SHM segment (shmop_read)' . "\n" ) ; } unset ( $ this -> internalIPCArray ) ; $ th...
Read from IPC segment
52,522
public function register_callback_func ( $ argList , $ methodName ) { if ( is_array ( $ argList ) && count ( $ argList ) > 1 ) { if ( $ argList [ 1 ] === - 2 ) { $ this -> internalIPCArray [ '_call_type' ] = - 2 ; } else { $ this -> internalIPCArray [ '_call_type' ] = - 1 ; } } else { $ this -> internalIPCArray [ '_cal...
Register callback func into shared memory
52,523
protected function cleanThreadContext ( ) { shmop_delete ( $ this -> internalIPCKey ) ; shmop_delete ( $ this -> internalSemaphoreKey ) ; shmop_close ( $ this -> internalIPCKey ) ; shmop_close ( $ this -> internalSemaphoreKey ) ; unlink ( $ this -> fileIPC1 ) ; unlink ( $ this -> fileIPC2 ) ; $ this -> running = false ...
Clean thread context
52,524
protected static function createContainer ( ) { $ app = JFactory :: getApplication ( ) ; if ( is_null ( $ app -> get ( 'container' , null ) ) ) { $ app -> set ( 'container' , new Container ( ) ) ; } $ container = $ app -> get ( 'container' ) ; if ( ! method_exists ( $ container , 'set' ) ) { $ container = new Container...
Ensure container exists
52,525
protected static function createDatabaseConfiguration ( ) { $ config = new JConfig ( ) ; $ dsn = $ config -> dbtype . '://' . $ config -> user . ':' . $ config -> password . '@' . $ config -> host . '/' . $ config -> db ; $ dataMapperClass = PrefixedDoctrineDataMapper :: class ; $ ini = <<<INIdatabaseUrl="$dsn"definit...
Create DB configuration
52,526
public function getByModelRootId ( $ rootId ) { $ this -> fillScopes ( ) ; if ( ! isset ( $ this -> scopeByModelRootId [ $ rootId ] ) ) { throw new OutOfBoundsException ( "No scope with modelRootId '$rootId' found" ) ; } return $ this -> scopeByModelRootId [ $ rootId ] ; }
Returns the scope by modelRootId
52,527
protected function fillScopes ( ) { if ( $ this -> scopes !== null ) { return ; } $ this -> scopes = [ ] ; foreach ( $ this -> treeModel -> rootNodes ( ) as $ rootNode ) { $ this -> addToScopes ( $ this -> node2Scope ( $ rootNode ) ) ; } foreach ( $ this -> manualScopes as $ scope ) { $ this -> addToScopes ( $ scope ) ...
Fills the scope array for fast lookups
52,528
protected function addToScopes ( TreeScope $ scope ) { $ this -> scopes [ ] = $ scope ; $ this -> scopeByName [ $ scope -> getName ( ) ] = $ scope ; $ this -> scopeByModelRootId [ $ scope -> getModelRootId ( ) ] = $ scope ; $ this -> scopeByPathPrefix [ $ scope -> getPathPrefix ( ) ] = $ scope ; }
Adds the passed scope to the scope array
52,529
public function node2Scope ( SiteTreeNodeInterface $ node ) { $ scope = new TreeScope ( ) ; $ urlSegment = trim ( $ node -> getUrlSegment ( ) , '/' ) ; $ name = $ urlSegment ? $ urlSegment : TreeScope :: DEFAULT_NAME ; $ scope -> setPathPrefix ( $ node -> getUrlSegment ( ) ) ; $ scope -> setName ( $ name ) ; $ scope ->...
Convert a root node to a scope
52,530
public function getPages ( ) { $ pages = array ( ) ; foreach ( $ this -> router -> getRouteCollection ( ) -> all ( ) as $ route ) { if ( $ method = $ this -> getReflectionMethod ( $ route -> getDefault ( '_controller' ) ) ) { if ( $ composerAnnotation = $ this -> reader -> getMethodAnnotation ( $ method , self :: COMPO...
Gets all existing Pages
52,531
private function getReflectionMethod ( $ controller ) { if ( preg_match ( '#(.+)::([\w]+)#' , $ controller , $ matches ) ) { $ class = $ matches [ 1 ] ; $ method = $ matches [ 2 ] ; } elseif ( preg_match ( '#(.+):([\w]+)#' , $ controller , $ matches ) ) { $ controller = $ matches [ 1 ] ; $ method = $ matches [ 2 ] ; if...
Returns the ReflectionMethod for the given controller string
52,532
public function upPagesPosition ( $ parentId , $ position , $ positionLimit = NULL ) { if ( is_null ( $ positionLimit ) ) { $ query = $ this -> getEntityManager ( ) -> createQuery ( 'UPDATE FulgurioLightCMSBundle:Page p SET p.position=p.position-1 WHERE p.position>=:position AND p.parent=:parentId AND p.page_type=:page...
Up pages position
52,533
public function getNextPosition ( $ parentId ) { $ query = $ this -> getEntityManager ( ) -> createQuery ( 'SELECT MAX(p.position) FROM FulgurioLightCMSBundle:Page p WHERE p.parent=:parentId AND p.page_type=:pageType' ) ; $ query -> setParameter ( 'pageType' , 'page' ) ; $ query -> setParameter ( 'parentId' , $ parentI...
Get next position in tree
52,534
public static function validateTags ( array & $ array , $ direction = null ) { foreach ( $ array as $ key => $ tag ) { $ array [ $ key ] = self :: validateTag ( $ tag , $ direction ) ; } return $ array ; }
Validates that the given array contains all valid Tag entries
52,535
public static function matchTags ( array $ tags1 , array $ tags2 ) { if ( count ( self :: diffTags ( $ tags1 , $ tags2 ) ) == 0 && count ( self :: diffTags ( $ tags2 , $ tags1 ) ) == 0 ) return true ; return false ; }
Determines if the tags in both arrays are a match
52,536
public function setValue ( $ value ) { if ( ! $ this -> validate ( $ value ) ) { throw new InvalidClaimException ( 'Invalid value provided for claim "' . $ this -> getName ( ) . '": ' . $ value ) ; } $ this -> value = $ value ; return $ this ; }
Set the claim value and call a validate method if available .
52,537
public function fakeUrl ( $ route , $ params ) { if ( preg_match_all ( '/\[[\s\S]+?]/' , $ route , $ matches , PREG_SET_ORDER ) ) { for ( $ i = 0 ; $ i < count ( $ matches ) ; $ i ++ ) { $ route = preg_replace ( '/\[[\s\S]+?]/' , $ params [ $ i ] , $ route ) ; } } return ( $ route ) ; }
Return the real url genereted from a named route
52,538
public static function fromNative ( ) { $ args = \ func_get_args ( ) ; if ( \ count ( $ args ) != 2 ) { throw new \ BadMethodCallException ( 'You must provide 2 arguments: 1) real part, 2) imaginary part' ) ; } $ real = Real :: fromNative ( $ args [ 0 ] ) ; $ im = Real :: fromNative ( $ args [ 1 ] ) ; $ complex = new s...
Returns a new Complex object from native PHP arguments
52,539
public static function fromPolar ( Real $ modulus , Real $ argument ) { $ realValue = $ modulus -> toNative ( ) * \ cos ( $ argument -> toNative ( ) ) ; $ imValue = $ modulus -> toNative ( ) * \ sin ( $ argument -> toNative ( ) ) ; $ real = new Real ( $ realValue ) ; $ im = new Real ( $ imValue ) ; $ complex = new self...
Returns a Complex given polar coordinates
52,540
public static function parse ( string $ headerValue ) : self { $ self = new self ( ) ; foreach ( explode ( ',' , $ headerValue ) as $ acceptable ) { if ( strstr ( $ acceptable , 'q=' ) !== false ) { list ( $ acceptable , $ priority ) = explode ( 'q=' , trim ( $ acceptable ) ) ; } else { $ priority = 1 ; } settype ( $ p...
method to create an instance from a string header value
52,541
public function addAcceptable ( string $ acceptable , float $ priority = 1.0 ) : self { if ( 0 > $ priority || 1.0 < $ priority ) { throw new \ InvalidArgumentException ( 'Invalid priority, must be between 0 and 1.0' ) ; } $ this -> acceptables [ $ acceptable ] = $ priority ; return $ this ; }
add an acceptable to the list
52,542
public function priorityFor ( string $ mimeType ) : float { if ( ! isset ( $ this -> acceptables [ $ mimeType ] ) ) { if ( $ this -> count ( ) === 0 ) { return 1.0 ; } elseif ( isset ( $ this -> acceptables [ '*/*' ] ) ) { return $ this -> acceptables [ '*/*' ] ; } list ( $ maintype ) = explode ( '/' , $ mimeType ) ; r...
returns priority for given acceptable
52,543
public function asString ( ) : string { $ parts = [ ] ; foreach ( $ this -> acceptables as $ acceptable => $ priority ) { if ( 1.0 === $ priority ) { $ parts [ ] = $ acceptable ; } else { $ parts [ ] = $ acceptable . ';q=' . $ priority ; } } return join ( ',' , $ parts ) ; }
returns current list as string
52,544
protected function castToPhp ( $ value , $ column ) { if ( $ value !== null && $ this -> hasCast ( $ column ) && ! $ this -> isIgnoreCast ( $ value ) ) { $ value = $ this -> toPhpType ( $ value , $ this -> casts [ $ column ] ) ; } return $ value ; }
Cast column value to PHP type
52,545
protected function castToDb ( $ value , $ column ) { if ( $ this -> hasCast ( $ column ) && ! $ this -> isIgnoreCast ( $ value ) ) { $ value = $ this -> toDbType ( $ value , $ this -> casts [ $ column ] ) ; } return $ value ; }
Cast column value for saving to database
52,546
protected function toDbType ( $ value , $ type ) { switch ( $ type ) { case 'int' : return ( int ) $ value ; case 'bool' : return ( bool ) $ value ; case 'string' : case 'datetime' : case 'date' : case 'float' : return ( string ) $ value ; case 'array' : case 'json' : return json_encode ( ( array ) $ value , JSON_UNESC...
Cast value for saving to database
52,547
protected function cacheJsonDecode ( $ value , $ assoc = false ) { if ( ! isset ( static :: $ castCache [ $ value ] [ $ assoc ] ) ) { static :: $ castCache [ $ value ] [ $ assoc ] = json_decode ( $ value , $ assoc ) ; } return static :: $ castCache [ $ value ] [ $ assoc ] ; }
Cache json decode value
52,548
static public function makeApp ( $ envPath = null , array $ config = [ ] , $ kernel = null ) { $ envPath = is_null ( $ envPath ) ? static :: getRuntimePath ( ) : $ envPath ; $ kernel = is_null ( $ kernel ) ? static :: defaultKernel ( ) : $ kernel ; $ config = empty ( $ config ) ? static :: defaultConfig ( ) : $ config ...
Static factor constructor .
52,549
public function config ( ) { if ( $ this -> appConfig ) { return $ this -> appConfig ; } return $ this -> appConfig = $ this -> app -> make ( 'config' ) ; }
Get application config repository ;
52,550
protected function bootComponents ( ) { $ config = $ this -> config ( ) ; foreach ( $ this -> componentInstances as $ instance ) { $ instance -> boot ( $ this -> app , $ config ) ; } }
Boot setup components .
52,551
protected function setupComponents ( ) { $ components = Arr :: get ( $ this -> config , 'components' ) ; foreach ( $ components as $ component ) { $ instance = new $ component ( $ this -> config ) ; $ instance -> setup ( ) ; $ this -> componentInstances [ $ component ] = $ instance ; } }
Build component instances and run setup method .
52,552
protected function buildAppConfig ( $ configPath ) { $ config = require ( $ configPath ) ; $ callback = Arr :: get ( $ this -> config , 'callback.vendor_config' ) ; if ( $ callback instanceof Closure ) { $ config = call_user_func ( $ callback , $ config ) ; } return $ config ; }
Include and add our Service Provider to the App config .
52,553
static public function getRuntimePath ( $ depth = 2 ) { $ stack = debug_backtrace ( ) ; $ frame = $ stack [ count ( $ stack ) - $ depth ] ; return dirname ( $ frame [ 'file' ] ) ; }
Get the file location of the calling file .
52,554
public function addDefaultParam ( $ templateName , $ param , $ value ) { $ isDefaultForAllTemplates = ( $ templateName === self :: TEMPLATE_ALL ) ; if ( $ isDefaultForAllTemplates ) { $ this -> defaultParameters [ $ param ] = $ value ; $ this -> defaultParametersProvided = true ; } else { $ this -> fullQualifiedPathNam...
Add a default parameter to use with a template .
52,555
public static function generateCustom ( $ prefix , $ length = 128 ) { if ( $ length <= ( strlen ( $ prefix ) + 1 ) ) { throw new InvalidArgumentException ( "Uid length cannot be smaller than prefix length +1" ) ; } return "$prefix-" . self :: generate ( $ length - ( strlen ( $ prefix ) + 1 ) ) ; }
Generate a custom uid starting from a prefix
52,556
public static function generate ( $ length = 128 ) { if ( $ length < 32 ) { return substr ( self :: getUid ( ) , 0 , $ length ) ; } else if ( $ length == 32 ) { return self :: getUid ( ) ; } else { $ numString = ( int ) ( $ length / 32 ) + 1 ; $ randNum = "" ; for ( $ i = 0 ; $ i < $ numString ; $ i ++ ) $ randNum .= s...
Generate an uid
52,557
public static function load ( string $ fileName , ImageDriver $ driver = null ) : self { $ self = new self ( $ fileName , $ driver ) ; $ self -> handle = $ self -> driver -> load ( $ fileName ) ; return $ self ; }
loads image from file
52,558
public function store ( string $ fileName ) : self { $ this -> driver -> store ( $ fileName , $ this -> handle ) ; return $ this ; }
stores image under given file name
52,559
static function MemberCheckList ( $ name , Member $ member ) { $ field = new CheckList ( $ name ) ; self :: AddMembergroupOptions ( $ field ) ; $ groupIDs = Membergroup :: GetKeyList ( self :: MemberMembergroups ( $ member ) ) ; $ field -> SetValue ( $ groupIDs ) ; return $ field ; }
Creates a check list field for groups of a member
52,560
static function PageCheckList ( $ name , Page $ page ) { $ field = new CheckList ( $ name ) ; self :: AddMembergroupOptions ( $ field ) ; $ groupIDs = Membergroup :: GetKeyList ( self :: PageMembergroups ( $ page ) ) ; $ field -> SetValue ( $ groupIDs ) ; return $ field ; }
Creates a check list field for groups of a page
52,561
static function ContentCheckList ( $ name , Content $ content ) { $ field = new CheckList ( $ name ) ; self :: AddMembergroupOptions ( $ field ) ; $ groupIDs = Membergroup :: GetKeyList ( self :: ContentMembergroups ( $ content ) ) ; $ field -> SetValue ( $ groupIDs ) ; return $ field ; }
Creates a check list field for groups of a content
52,562
static function MemberMembergroups ( Member $ member ) { if ( ! $ member -> Exists ( ) ) { return array ( ) ; } $ sql = Access :: SqlBuilder ( ) ; $ tblMmg = MemberMembergroup :: Schema ( ) -> Table ( ) ; $ tblMg = Membergroup :: Schema ( ) -> Table ( ) ; $ join = $ sql -> Join ( $ tblMmg ) ; $ joinCondition = $ sql ->...
Gets the member s member groups
52,563
static function PageMembergroups ( Page $ page ) { if ( ! $ page -> Exists ( ) ) { return array ( ) ; } $ sql = Access :: SqlBuilder ( ) ; $ tblPmg = PageMembergroup :: Schema ( ) -> Table ( ) ; $ tblMg = Membergroup :: Schema ( ) -> Table ( ) ; $ join = $ sql -> Join ( $ tblPmg ) ; $ joinCondition = $ sql -> Equals ( ...
Gets the page s member groups
52,564
static function ContentMembergroups ( Content $ content ) { if ( ! $ content -> Exists ( ) ) { return array ( ) ; } $ sql = Access :: SqlBuilder ( ) ; $ tblCmg = ContentMembergroup :: Schema ( ) -> Table ( ) ; $ tblMg = Membergroup :: Schema ( ) -> Table ( ) ; $ join = $ sql -> Join ( $ tblCmg ) ; $ joinCondition = $ s...
Gets the content s member groups
52,565
private static function AddMembergroupOptions ( CheckList $ field ) { $ sql = Access :: SqlBuilder ( ) ; $ tbl = Membergroup :: Schema ( ) -> Table ( ) ; $ orderBy = $ sql -> OrderList ( $ sql -> OrderAsc ( $ tbl -> Field ( 'Name' ) ) ) ; $ groups = Membergroup :: Schema ( ) -> Fetch ( false , null , $ orderBy ) ; fore...
Adds the member group options to the checklist
52,566
public function getRoles ( ) { $ roles = $ this -> roles ; foreach ( $ this -> getGroups ( ) as $ group ) { $ roles = array_merge ( $ roles , $ group -> getRoles ( ) ) ; } $ newRoles = [ ] ; if ( $ this -> getActiveRole ( ) ) { $ newRoles = $ this -> getActiveRole ( ) -> getRoles ( ) ; } $ finalRoles = array_merge ( $ ...
Returns the user roles
52,567
public function build ( ) { $ values = array ( 'access' => false , 'genres' => false , 'publication_date' => false , 'title' => true , 'keywords' => true , 'stock_tickers' => true ) ; foreach ( $ values as $ value => $ isEscaped ) { if ( ! is_null ( $ this -> { $ value } ) ) { $ this -> addChild ( sprintf ( 'news:%s' ,...
Adds all the nodes in our news sitemap with some values being escaped .
52,568
public function setMaxLengths ( $ column1 = null , $ column2 = null , $ _ = null ) { foreach ( func_get_args ( ) as $ index => $ argument ) { $ length = strlen ( ( string ) $ argument ) ; if ( $ this -> columns -> offsetExists ( $ index ) === false || $ this -> columns -> offsetGet ( $ index ) < $ length ) { $ this -> ...
Set the max column lengths for later use
52,569
public function getColumnPaddingLength ( $ columnIndex , $ columnValue ) { if ( $ this -> columns -> offsetExists ( $ columnIndex ) === false ) { return 0 ; } return $ this -> columns -> offsetGet ( $ columnIndex ) - strlen ( $ columnValue ) ; }
Get the padding needed based on the max column length and the column value given
52,570
public function addInstance ( Curl $ curlInstance , $ name = null ) { if ( $ name ) { $ this -> curlInstances [ $ name ] = $ curlInstance ; } else { $ this -> curlInstances [ ] = $ curlInstance ; } end ( $ this -> curlInstances ) ; return key ( $ this -> curlInstances ) ; }
Add a Curl instance to this Curl Multi instance
52,571
public function setOpt ( $ option , $ value ) { foreach ( $ this -> curlInstances as $ instance ) { $ instance -> setOpt ( $ option , $ value ) ; } }
Set the given cURL option for all previously added cURL instances .
52,572
private function subExec ( $ instances , $ retryCount = 0 , $ retryWait = 0 ) { $ curlMultiInstance = curl_multi_init ( ) ; foreach ( $ instances as $ name => $ curlInstance ) { curl_multi_add_handle ( $ curlMultiInstance , $ curlInstance -> getHandle ( ) ) ; } do { curl_multi_exec ( $ curlMultiInstance , $ stillRunnin...
Execute the requests of all given Curl instances
52,573
public function exec ( $ maxRequests = null , $ retryCount = 0 , $ retryWait = 0 , $ waitBetweenChunks = 0 ) { if ( $ maxRequests == null or $ maxRequests <= 0 ) { $ this -> subExec ( $ this -> curlInstances , $ retryCount , $ retryWait ) ; return ; } $ instanceChunks = array_chunk ( $ this -> curlInstances , $ maxRequ...
Execute the requests of all added Curl instances
52,574
public function removeInstance ( $ instanceName ) { $ curlInstance = $ this -> curlInstances [ $ instanceName ] ; unset ( $ this -> curlInstances [ $ instanceName ] ) ; return $ curlInstance ; }
Remove the specified instance given by the name
52,575
public function retryFailed ( $ curlInstances ) { $ failed = 0 ; $ curlMultiInstance = new CurlMulti ( ) ; foreach ( $ curlInstances as $ curlInstance ) { if ( $ curlInstance -> isSuccessful ( ) ) { continue ; } $ curlInstance -> setRetryCount ( $ curlInstance -> getRetryCount ( ) + 1 ) ; $ curlMultiInstance -> addInst...
Retry all failed requests of the given array of Curl instances .
52,576
public function getDecode ( Comm $ item , $ lead = null ) { $ comt = json_decode ( $ item -> comment ) ; if ( $ comt -> frontmatter -> title ) { $ til = $ comt -> frontmatter -> title ; } else { $ til = $ item -> title ; } $ comt = $ comt -> text ; if ( $ lead ) { return '<h3>' . $ til . '</h3><p>' . $ comt . '</p>' ; ...
Returns json_decoded title and text If lead text headline is larger font
52,577
public function getEdit ( $ isadmin , $ userid , $ commid , $ htmlcomment ) { $ update = $ this -> setUrlCreator ( "comm/update" ) ; if ( $ isadmin || $ userid == $ this -> sess [ 'id' ] ) { $ edit = '<p><a href="' . $ update . '/' . $ commid . '">Redigera</a> | ' ; $ edit .= $ htmlcomment ; } else { $ edit = "<p>" . $...
If loggedin allowed to edit
52,578
public function writeXML ( \ XMLWriter $ w , string $ elementName = 'ImageSizeReducers' ) { if ( ! empty ( $ elementName ) ) { $ w -> startElement ( $ elementName ) ; } foreach ( $ this as $ reducer ) { if ( \ is_null ( $ reducer ) || ! ( $ reducer instanceof ImageSizeReducer ) ) { continue ; } $ reducer -> writeXML ( ...
Writes the current instance data to defined XMLWriter .
52,579
public function dispatch ( ) { if ( $ this -> isDispatchable ( ) ) { $ sorted = [ ] ; foreach ( $ this -> attachedToEvents as $ eventName ) { $ sorted [ $ eventName ] = $ this -> dispatchedEvents [ $ eventName ] ; } call_user_func ( $ this -> listener , $ sorted ) ; if ( $ this -> purge ) { $ this -> dispatchedEvents =...
Try to dispatch the event and clear the event cache
52,580
protected function _normalizePath ( $ path , $ separator ) { try { return $ this -> _normalizeIterable ( $ path ) ; } catch ( InvalidArgumentException $ e ) { return $ this -> _stringableSplit ( $ path , $ separator ) ; } }
Normalizes a path .
52,581
public function askForArray ( OutputInterface $ output , $ question , $ default ) { $ result = $ this -> ask ( $ output , $ question , $ default ) ; if ( is_string ( $ result ) ) { $ result = explode ( ',' , $ result ) ; } if ( ! is_array ( $ result ) ) { $ result = array ( ) ; } $ result = array_map ( 'trim' , $ resul...
Asks for a list of values the response is split to return an array
52,582
public function amountOfDays ( ) : int { return $ this -> end -> handle ( ) -> diff ( $ this -> start -> handle ( ) ) -> days + 1 ; }
returns amount of days in this datespan
52,583
public function isInFuture ( ) : bool { $ today = mktime ( 23 , 59 , 59 , ( int ) date ( 'm' ) , ( int ) date ( 'd' ) , ( int ) date ( 'Y' ) ) ; if ( $ this -> start -> timestamp ( ) > $ today ) { return true ; } return false ; }
checks whether the DateSpan is in the future compared to current date
52,584
public function containsDate ( $ date ) : bool { $ date = Date :: castFrom ( $ date ) ; if ( ! $ this -> start -> isBefore ( $ date ) && ! $ this -> start -> equals ( $ date ) ) { return false ; } if ( ! $ this -> end -> isAfter ( $ date ) && ! $ this -> end -> equals ( $ date ) ) { return false ; } return true ; }
checks whether the span contains the given date
52,585
final public function handle ( CommandInterface $ command ) { $ this -> validateCommand ( $ command ) ; try { $ this -> _handle ( $ command ) ; } catch ( \ Exception $ exception ) { $ commandClass = get_class ( $ command ) ; $ this -> logError ( "Exception throw while handling {$commandClass} command... {$exception->ge...
Processes the associated command
52,586
function logError ( $ errorMessage , \ Exception $ exception ) { if ( $ this -> logger instanceof LoggerInterface ) { $ this -> logger -> error ( $ errorMessage . "\n" . $ exception -> getTraceAsString ( ) ) ; } }
Logs an error if the error logger is available
52,587
public function Link ( $ action = null ) { if ( $ this -> currentRecord ) { return Controller :: join_links ( $ this -> parentController -> Link ( ) , "/{$this->currentRecord->ID}/{$action}" ) ; } else { return $ this -> parentController -> Link ( ) ; } }
Link fragment - appends the current record ID to the URL .
52,588
public function view ( $ request ) { if ( ! $ this -> currentRecord ) { return $ this -> httpError ( 404 , "{$this->recordType} not found" ) ; } if ( ! $ this -> currentRecord -> canView ( ) ) { return $ this -> httpError ( 403 , "You do not have permission to view this {$this->recordType}" ) ; } $ form = $ this -> For...
Returns the view of the record
52,589
public function edit ( $ request ) { if ( ! $ this -> currentRecord ) { return $ this -> httpError ( 404 , "{$this->recordType} not found" ) ; } if ( ! $ this -> currentRecord -> canEdit ( ) ) { return $ this -> httpError ( 403 , "You do not have permission to edit this {$this->recordType}" ) ; } $ this -> addCrumb ( '...
Returns a form for editing the record
52,590
function getViewer ( $ action ) { if ( $ this -> parentController ) { if ( is_numeric ( $ action ) ) { $ action = 'view' ; } $ viewer = $ this -> parentController -> getViewer ( $ action ) ; $ layoutTemplate = null ; $ layoutTemplate = SSViewer :: getTemplateFileByType ( "{$this->recordType}_$action" , 'Layout' ) ; if ...
If a parentcontroller exists use its main template and mix in specific collectioncontroller subtemplates .
52,591
public function Form ( ) { if ( $ this -> currentRecord ) { $ fields = $ this -> currentRecord -> getFrontEndFields ( ) ; $ required = $ this -> currentRecord -> getRequiredFields ( ) ; } else { $ fields = singleton ( $ this -> recordType ) -> getFrontEndFields ( ) ; $ required = singleton ( $ this -> recordType ) -> g...
Scaffolds the fields required for editing the record
52,592
public function doSave ( $ data , $ form ) { if ( ! $ this -> currentRecord ) { $ this -> currentRecord = new $ this -> recordType ( ) ; } $ form -> saveInto ( $ this -> currentRecord ) ; $ this -> currentRecord -> write ( ) ; $ this -> redirect ( $ this -> Link ( ) ) ; }
Save the record
52,593
public function httpError ( $ code , $ message = null ) { if ( $ this -> request -> isMedia ( ) || ! $ response = ErrorPage :: response_for ( $ code ) ) { parent :: httpError ( $ code , $ message ) ; } else { throw new HTTPResponse_Exception ( $ response ) ; } }
Show a pretty error if possible
52,594
public function addCrumb ( $ title , $ link = null ) { $ this -> Title = $ title ; if ( $ link ) { array_push ( $ this -> crumbs , "<a href=\"$link\">$title</a>" ) ; } else { array_push ( $ this -> crumbs , $ title ) ; } }
Adds a breadcrumb action
52,595
public function Breadcrumbs ( ) { $ parts = explode ( self :: $ breadcrumbs_delimiter , $ this -> parentController -> Breadcrumbs ( ) ) ; array_pop ( $ parts ) ; array_push ( $ parts , '<a href="' . $ this -> parentController -> Link ( ) . '">' . $ this -> parentController -> Title . '</a>' ) ; array_pop ( $ this -> cr...
Build on the breadcrumbs to show the nested actions
52,596
public function addReplacer ( array $ replacer ) { foreach ( $ replacer as $ key => $ value ) { Unicode :: $ char [ $ key ] = $ value ; } }
Add array list for replacer
52,597
public function replaceText ( string $ str ) : string { foreach ( Unicode :: $ char as $ key => $ value ) { if ( $ key === $ str ) { $ result = ( ( count ( $ value ) > 1 ) ? Unicode :: $ char [ $ key ] [ random_int ( 0 , count ( $ value ) - 1 ) ] : Unicode :: $ char [ $ key ] [ 0 ] ) ; } } return $ result ?? $ str ; }
Replace text with unicode character
52,598
public function encode ( ) { foreach ( $ this -> body as $ key => $ value ) { $ result [ ] = $ this -> replaceText ( $ value ) ; } return implode ( '' , $ result ) ; }
Replace character with new unicode character
52,599
public function build ( $ sql = '' ) { $ sql .= "\n" ; if ( ! empty ( $ this -> selectParams [ self :: SELECT ] ) ) { $ sql = "SELECT " . implode ( ",\n" , $ this -> selectParams [ self :: SELECT ] ) ; } if ( ! empty ( $ this -> selectParams [ self :: FROM ] ) ) { $ sql .= "\nFROM " . implode ( ",\n" , $ this -> select...
Creates the SQL query