idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
1,600
public function attach ( $ callback , $ priority = self :: DEFAULT_PRIORITY ) { if ( ! is_callable ( $ callback ) ) { if ( ! $ callback instanceof FilterInterface ) { throw new Exception \ InvalidArgumentException ( sprintf ( 'Expected a valid PHP callback; received "%s"' , ( is_object ( $ callback ) ? get_class ( $ callback ) : gettype ( $ callback ) ) ) ) ; } $ callback = [ $ callback , 'filter' ] ; } $ this -> filters -> insert ( $ callback , $ priority ) ; return $ this ; }
Attach a filter to the chain
1,601
public function attachByName ( $ name , $ options = [ ] , $ priority = self :: DEFAULT_PRIORITY ) { if ( ! is_array ( $ options ) ) { $ options = ( array ) $ options ; } elseif ( empty ( $ options ) ) { $ options = null ; } $ filter = $ this -> getPluginManager ( ) -> get ( $ name , $ options ) ; return $ this -> attach ( $ filter , $ priority ) ; }
Attach a filter to the chain using a short name
1,602
public function merge ( FilterChain $ filterChain ) { foreach ( $ filterChain -> filters -> toArray ( PriorityQueue :: EXTR_BOTH ) as $ item ) { $ this -> attach ( $ item [ 'data' ] , $ item [ 'priority' ] ) ; } return $ this ; }
Merge the filter chain with the one given in parameter
1,603
public static function number ( int $ min = 0 , int $ max = PHP_INT_MAX ) : int { if ( $ max === $ min ) { return $ max ; } $ rand = static :: bytes ( 4 ) ; $ rand = hexdec ( bin2hex ( $ rand ) ) ; return $ min + abs ( $ rand % ( $ max - $ min + 1 ) ) ; }
Generate a random number from a range .
1,604
public function ColumnExists ( $ ColumnName ) { $ Result = array_key_exists ( $ ColumnName , $ this -> ExistingColumns ( ) ) ; if ( ! $ Result ) { foreach ( $ this -> ExistingColumns ( ) as $ ColName => $ Def ) { if ( strcasecmp ( $ ColumnName , $ ColName ) == 0 ) return TRUE ; } return FALSE ; } return $ Result ; }
Returns whether or not a column exists in the database .
1,605
public function ColumnTypeString ( $ Column ) { if ( is_string ( $ Column ) ) $ Column = $ this -> _Columns [ $ Column ] ; $ Type = GetValue ( 'Type' , $ Column ) ; $ Length = GetValue ( 'Length' , $ Column ) ; $ Precision = GetValue ( 'Precision' , $ Column ) ; if ( in_array ( strtolower ( $ Type ) , array ( 'tinyint' , 'smallint' , 'mediumint' , 'int' , 'float' , 'double' ) ) ) $ Length = NULL ; if ( $ Type && $ Length && $ Precision ) $ Result = "$Type($Length, $Precision)" ; elseif ( $ Type && $ Length ) $ Result = "$Type($Length)" ; elseif ( strtolower ( $ Type ) == 'enum' ) { $ Result = GetValue ( 'Enum' , $ Column , array ( ) ) ; } elseif ( $ Type ) $ Result = $ Type ; else $ Result = 'int' ; return $ Result ; }
Return the definition string for a column .
1,606
public function Get ( $ TableName = '' ) { if ( $ TableName ) $ this -> Table ( $ TableName ) ; $ Columns = $ this -> Database -> SQL ( ) -> FetchTableSchema ( $ this -> _TableName ) ; $ this -> _Columns = $ Columns ; return $ this ; }
Load the schema for this table from the database .
1,607
public function PrimaryKey ( $ Name , $ Type = 'int' ) { $ Column = $ this -> _CreateColumn ( $ Name , $ Type , FALSE , NULL , 'primary' ) ; $ Column -> AutoIncrement = TRUE ; $ this -> _Columns [ $ Name ] = $ Column ; return $ this ; }
Defines a primary key column on a table .
1,608
public function Query ( $ Sql ) { if ( $ this -> CaptureOnly ) { if ( ! property_exists ( $ this -> Database , 'CapturedSql' ) ) $ this -> Database -> CapturedSql = array ( ) ; $ this -> Database -> CapturedSql [ ] = $ Sql ; return TRUE ; } else { $ Result = $ this -> Database -> Query ( $ Sql ) ; return $ Result ; } }
Send a query to the database and return the result .
1,609
public function Table ( $ Name = '' , $ CharacterEncoding = '' ) { if ( ! $ Name ) return $ this -> _TableName ; $ this -> _TableName = $ Name ; if ( $ CharacterEncoding == '' ) $ CharacterEncoding = Gdn :: Config ( 'Database.CharacterEncoding' , '' ) ; $ this -> _CharacterEncoding = $ CharacterEncoding ; return $ this ; }
Specifies the name of the table to create or modify .
1,610
public function TableExists ( $ TableName = NULL ) { if ( $ this -> _TableExists === NULL || $ TableName !== NULL ) { if ( $ TableName === NULL ) $ TableName = $ this -> TableName ( ) ; if ( strlen ( $ TableName ) > 0 ) { $ Tables = $ this -> Database -> SQL ( ) -> FetchTables ( ':_' . $ TableName ) ; $ Result = count ( $ Tables ) > 0 ; } else { $ Result = FALSE ; } if ( $ TableName == $ this -> TableName ( ) ) $ this -> _TableExists = $ Result ; return $ Result ; } return $ this -> _TableExists ; }
Whether or not the table exists in the database .
1,611
public function Types ( $ Class = 'all' ) { $ Date = array ( 'datetime' , 'date' ) ; $ Decimal = array ( 'decimal' , 'numeric' ) ; $ Float = array ( 'float' , 'double' ) ; $ Int = array ( 'int' , 'tinyint' , 'smallint' , 'mediumint' , 'bigint' ) ; $ String = array ( 'varchar' , 'char' , 'mediumtext' , 'text' ) ; $ Length = array ( 'varbinary' ) ; $ Other = array ( 'enum' , 'tinyblob' , 'blob' , 'mediumblob' , 'longblob' ) ; switch ( strtolower ( $ Class ) ) { case 'date' : return $ Date ; case 'decimal' : return $ Decimal ; case 'float' : return $ Float ; case 'int' : return $ Int ; case 'string' : return $ String ; case 'other' : return array_merge ( $ Length , $ Other ) ; case 'numeric' : return array_merge ( $ Foat , $ Int , $ Decimal ) ; case 'length' : return array_merge ( $ String , $ Length , $ Decimal ) ; case 'precision' : return $ Decimal ; default : return array ( ) ; } }
Gets an arrya of type names allowed in the structure .
1,612
public function ExistingColumns ( ) { if ( $ this -> _ExistingColumns === NULL ) { if ( $ this -> TableExists ( ) ) $ this -> _ExistingColumns = $ this -> Database -> SQL ( ) -> FetchTableSchema ( $ this -> _TableName ) ; else $ this -> _ExistingColumns = array ( ) ; } return $ this -> _ExistingColumns ; }
Gets the column definitions for the columns in the database .
1,613
public function Reset ( ) { $ this -> _CharacterEncoding = '' ; $ this -> _Columns = array ( ) ; $ this -> _ExistingColumns = NULL ; $ this -> _TableExists = NULL ; $ this -> _TableName = '' ; $ this -> _TableStorageEngine = NULL ; return $ this ; }
Reset the internal state of this object so that it can be reused .
1,614
public static function ToString ( $ Conditions ) { $ Result = '' ; foreach ( $ Conditions as $ Condition ) { if ( ! is_array ( $ Condition ) || count ( $ Condition ) < 2 ) continue ; if ( strlen ( $ Result ) > 0 ) $ Result .= "\n" ; $ Result .= "{$Condition[0]},{$Condition[1]}" ; if ( count ( $ Condition ) >= 3 ) { $ Result .= $ Condition [ 2 ] ; } } return $ Result ; }
Convert an array of conditions to a string .
1,615
public function collection ( $ data , \ Mickeyhead7 \ Rsvp \ Transformer \ TransformerAbstract $ transformer ) { return new Collection ( $ data , $ transformer ) ; }
Creates a new resource collection
1,616
public function item ( $ data , \ Mickeyhead7 \ Rsvp \ Transformer \ TransformerAbstract $ transformer ) { return new Item ( $ data , $ transformer ) ; }
Creates a new resource item
1,617
private function registerPermissions ( ) { collect ( [ 'admin_access' , ] ) -> map ( function ( $ permission ) { Gate :: define ( $ permission , function ( $ user ) use ( $ permission ) { if ( $ this -> nobodyHasAccess ( $ permission ) ) { return true ; } return $ user -> hasRoleWithPermission ( $ permission ) ; } ) ; } ) ; }
Register default package related permissions
1,618
private function registerBladeExtensions ( ) { Blade :: directive ( 'repeater' , function ( $ expression = [ ] ) { return "<?php echo \RenderEngine::renderRepeater({$expression}); ?>" ; } ) ; Blade :: directive ( 'field' , function ( $ expression = [ ] ) { return "<?php echo \RenderEngine::renderField({$expression}); ?>" ; } ) ; Blade :: directive ( 'render' , function ( $ expression = [ ] ) { return "<?php echo \RenderEngine::render({$expression}); ?>" ; } ) ; }
Register our blade extensions to easily render CMS content
1,619
public static function parseURL ( $ url , $ defaults = array ( ) ) { $ parts = is_string ( $ url ) ? \ parse_url ( urldecode ( $ url ) ) : $ url ; $ select = function ( $ k ) use ( $ parts , $ defaults ) { if ( isset ( $ parts [ $ k ] ) ) return $ parts [ $ k ] ; elseif ( isset ( $ defaults [ $ k ] ) ) return $ defaults [ $ k ] ; else return '' ; } ; $ url = array ( 'scheme' => $ select ( 'scheme' ) , 'host' => $ select ( 'host' ) , 'port' => $ select ( 'port' ) , 'user' => $ select ( 'user' ) , 'pass' => $ select ( 'pass' ) , 'path' => $ select ( 'path' ) , 'options' => array ( ) , ) ; if ( isset ( $ parts [ 'query' ] ) ) parse_str ( $ parts [ 'query' ] , $ url [ 'options' ] ) ; return $ url ; }
Parse a URL string into an array of components . Similar to the native parse_url except that the returned array will contain all components and the query component is replaced with an options component containing a decoded array .
1,620
public static function normaliseLineEndings ( $ str ) { $ str = str_replace ( "\r\n" , "\n" , $ str ) ; $ str = str_replace ( "\r" , "\n" , $ str ) ; return preg_replace ( "/\n{2,}/" , "\n\n" , $ str ) ; }
Ensures that a string has consistent line - endings . All line - ending are converted to LF with maximum of two consecutive .
1,621
public function get ( ) { foreach ( $ this -> _strategies as $ strategy ) { $ result = $ strategy -> get ( ) ; if ( $ result !== null ) { return $ result ; } } return null ; }
Returns the result of the first successful strategy .
1,622
public function handleBofhCommand ( Event $ event , Queue $ queue ) { $ this -> getLogger ( ) -> info ( '[BOFH] received a new command' ) ; $ this -> fetchExcuse ( $ event , $ queue ) ; }
Process the command
1,623
public function fetchExcuse ( $ event , $ queue ) { $ url = 'http://pages.cs.wisc.edu/~ballard/bofh/bofhserver.pl' ; $ request = new Request ( [ 'url' => $ url , 'resolveCallback' => function ( Response $ response ) use ( $ url , $ event , $ queue ) { $ code = $ response -> getStatusCode ( ) ; $ dom = new \ DOMDocument ( ) ; $ dom -> loadHTML ( $ response -> getBody ( ) ) ; $ xpath = new \ DOMXpath ( $ dom ) ; $ result = $ xpath -> query ( '/html/body/center/font[2]' ) ; if ( $ result -> length > 0 ) { $ queue -> ircPrivmsg ( $ event -> getSource ( ) , $ result -> item ( 0 ) -> nodeValue ) ; } if ( $ code !== 200 ) { $ this -> getLogger ( ) -> notice ( '[BOFH] Site responded with error' , [ 'code' => $ code , 'message' => $ data [ 'error' ] [ 'message' ] , ] ) ; $ queue -> ircPrivmsg ( $ event -> getSource ( ) , 'Sorry, no excuse was found' ) ; return ; } $ this -> getLogger ( ) -> info ( '[BOFH] Site successful return' ) ; } , 'rejectCallback' => function ( $ data , $ headers , $ code ) use ( $ event , $ queue ) { $ this -> getLogger ( ) -> notice ( '[BOFH] Site failed to respond' ) ; $ queue -> ircPrivmsg ( $ event -> getSource ( ) , 'Sorry, there was a problem communicating with the site' ) ; } , ] ) ; $ this -> getEventEmitter ( ) -> emit ( 'http.request' , [ $ request ] ) ; }
Fetch the URL and parse an excuse
1,624
protected function matchIp ( $ ip , array $ patterns ) { $ num = ip2long ( $ ip ) ; foreach ( $ patterns as $ pat ) { if ( ( $ num & $ pat [ 1 ] ) == $ pat [ 0 ] ) { return true ; } } return false ; }
Match ip with patterns
1,625
protected function processPattern ( array $ patterns ) { $ result = [ ] ; foreach ( $ patterns as $ pat ) { $ part = explode ( '/' , $ pat ) ; $ addr = ip2long ( $ part [ 0 ] ) ; $ mask = isset ( $ part [ 1 ] ) ? ( ( int ) $ part [ 1 ] ) : 32 ; $ mask = $ this -> getMask ( $ mask ) ; $ addr = $ addr & $ mask ; $ result [ ] = [ $ addr , $ mask ] ; } return $ result ; }
Pre - process ip matching pattern
1,626
protected function getMask ( $ length = 32 ) { $ bin = substr ( str_repeat ( '1' , $ length ) . str_repeat ( '0' , 32 ) , 0 , 32 ) ; return ip2long ( long2ip ( bindec ( $ bin ) ) ) ; }
Convert mask length to mask in decimal
1,627
public static function start ( $ application ) { self :: $ _application = $ application ; self :: $ _starting = true ; self :: $ _started = false ; $ application -> start ( ) ; self :: $ _starting = false ; self :: $ _started = true ; self :: $ _autostart = null ; if ( ! self :: $ _shutdownRegistered ) { register_shutdown_function ( array ( __CLASS__ , 'shutdown' ) ) ; self :: $ _shutdownRegistered = true ; } }
Starts a particular application instance
1,628
public static function application ( ) { if ( ! isset ( self :: $ _application ) ) { if ( ! empty ( self :: $ _autostart ) ) { self :: start ( self :: $ _autostart ) ; } else { throw new Exception ( 'No application initialized' ) ; } } return self :: $ _application ; }
Gets the current application instance
1,629
public function addPageComponent ( PageComponent $ pageComponent , $ position = - 1 ) { if ( ! is_int ( $ position ) ) { throw new \ InvalidArgumentException ( 'position should be of type int' ) ; } if ( $ position < 0 ) { $ position = count ( $ this -> pageComponents ) ; } Utils :: array_insert ( $ this -> pageComponents , $ pageComponent , $ position ) ; return $ this ; }
Adds a PageComponent to this Page .
1,630
public static function getPort ( ) : ? int { if ( isset ( $ _SERVER [ 'HTTP_X_FORWARDED_PORT' ] ) ) { return ( int ) $ _SERVER [ 'HTTP_X_FORWARDED_PORT' ] ; } if ( 'https' === ( $ _SERVER [ 'HTTP_X_FORWARDED_PROTO' ] ?? '' ) ) { return 443 ; } return isset ( $ _SERVER [ 'SERVER_PORT' ] ) ? ( int ) $ _SERVER [ 'SERVER_PORT' ] : null ; }
Returns the port of this request as string .
1,631
protected static function fixActive ( ) { add_action ( 'nav_menu_css_class' , function ( $ classes , $ item ) { global $ post ; if ( ! $ post ) { return $ classes ; } $ current_post_type = get_post_type_object ( get_post_type ( $ post -> ID ) ) ; $ current_post_type_slug = $ current_post_type -> rewrite [ "slug" ] ; $ menu_slug = strtolower ( trim ( $ item -> url ) ) ; $ is_current_based_on_url = strpos ( $ menu_slug , $ current_post_type_slug ) !== false ; $ active = false ; $ is_post_page = in_array ( $ post -> post_type , [ "page" , "post" ] ) ; if ( $ is_current_based_on_url ) { $ active = true ; } elseif ( in_array ( "current-menu-item" , $ classes ) && ! $ is_post_page ) { $ active = true ; } elseif ( in_array ( "current_page_parent" , $ classes ) && $ is_post_page ) { $ active = true ; } elseif ( in_array ( "current-menu-item" , $ classes ) && $ is_post_page ) { $ active = true ; } if ( $ active ) { $ classes [ ] = 'current-menu-item active' ; } return $ classes ; } , 10 , 2 ) ; }
Makes archive menu link active when viewing CPT single
1,632
public function set ( $ key , $ value ) { if ( ! $ value instanceof RepositoryInterface ) { throw new InvalidArgumentException ( "Only RepositoryInterface object can be putted in a " . "RepositoryMap." ) ; } return parent :: set ( $ key , $ value ) ; }
Puts a new repository in the map .
1,633
public function save ( $ var , $ val , $ ttl = null ) { if ( $ ttl === null ) $ ttl = $ this -> _ttl ; if ( apc_store ( $ this -> _prefix . $ var , $ val , $ ttl ) ) return $ val ; return null ; }
Save a named value to the cache
1,634
public function setAttributes ( $ attributes , $ force = false ) { if ( $ force ) { $ this -> attributes = $ attributes ; } else { $ this -> attributes = array_merge ( $ this -> attributes , $ attributes ) ; } }
set all attributes
1,635
public function exec ( ) { $ this -> ch = curl_init ( ) ; curl_setopt_array ( $ this -> ch , [ CURLOPT_URL => $ this -> url , CURLOPT_POSTFIELDS => $ this -> data , CURLOPT_CUSTOMREQUEST => $ this -> requestType , CURLOPT_HTTPHEADER => $ this -> createHeaders ( ) , CURLOPT_TIMEOUT_MS => intval ( $ this -> timeout * 1000 ) , CURLOPT_ENCODING => 'gzip' , CURLOPT_FAILONERROR => false , CURLOPT_HEADER => true , CURLOPT_RETURNTRANSFER => true , ] ) ; curl_setopt_array ( $ this -> ch , $ this -> extraOpts ) ; if ( $ this -> username && $ this -> password ) { curl_setopt ( $ this -> ch , CURLOPT_USERPWD , "{$this->username}:{$this->password}" ) ; } if ( $ this -> data !== null ) curl_setopt ( $ this -> ch , CURLOPT_POSTFIELDS , $ this -> data ) ; $ this -> beforeExec ( ) ; $ resultData = curl_exec ( $ this -> ch ) ; $ httpCode = curl_getinfo ( $ this -> ch , CURLINFO_HTTP_CODE ) ; if ( curl_errno ( $ this -> ch ) !== CURLE_OK ) { throw new Exception ( curl_error ( $ this -> ch ) , curl_errno ( $ this -> ch ) ) ; } $ response = new Response ( $ httpCode , $ resultData , curl_getinfo ( $ this -> ch , CURLINFO_HEADER_SIZE ) ) ; if ( $ httpCode >= 400 ) { throw new Exception ( "HTTP transfer error {$httpCode}" , null , $ httpCode , $ response ) ; } curl_close ( $ this -> ch ) ; return $ response ; }
exec curl request
1,636
public static function extract ( array $ data , string $ path ) { if ( '' === $ path ) { return $ data ; } $ steps = explode ( '.' , $ path ) ; $ actual = $ data ; foreach ( $ steps as $ step ) { if ( ! array_key_exists ( $ step , $ actual ) ) { return null ; } $ actual = $ actual [ $ step ] ; } return $ actual ; }
Fetch array data in dot notation path
1,637
public static function S2p ( $ theta , $ phi , $ r , array & $ p ) { $ u = [ 0 , 0 , 0 ] ; IAU :: S2c ( $ theta , $ phi , $ u ) ; IAU :: Sxp ( $ r , $ u , $ p ) ; return ; }
- - - - - - - i a u S 2 p - - - - - - -
1,638
public function getCreateRoute ( ) { if ( null === $ this -> createRoute ) { $ route = rtrim ( $ this -> getBaseRoute ( ) , '/' ) . '/' . $ this -> getCreateSuffix ( ) ; $ this -> setCreateRoute ( $ route ) ; } return $ this -> createRoute ; }
Retrieves create route
1,639
public function getReadRoute ( ) { if ( null === $ this -> readRoute ) { $ route = rtrim ( $ this -> getBaseRoute ( ) , '/' ) . '/' . $ this -> getReadSuffix ( ) ; $ this -> setReadRoute ( $ route ) ; } return $ this -> readRoute ; }
Retrieves read route
1,640
public function getUpdateRoute ( ) { if ( null === $ this -> updateRoute ) { $ route = rtrim ( $ this -> getBaseRoute ( ) , '/' ) . '/' . $ this -> getUpdateSuffix ( ) ; $ this -> setUpdateRoute ( $ route ) ; } return $ this -> updateRoute ; }
Retrieves update route
1,641
public function getDeleteRoute ( ) { if ( null === $ this -> deleteRoute ) { $ route = rtrim ( $ this -> getBaseRoute ( ) , '/' ) . '/' . $ this -> getDeleteSuffix ( ) ; $ this -> setDeleteRoute ( $ route ) ; } return $ this -> deleteRoute ; }
Retrieves delete route
1,642
public function getListRoute ( ) { if ( null === $ this -> listRoute ) { $ route = rtrim ( $ this -> getBaseRoute ( ) , '/' ) . '/' . $ this -> getListSuffix ( ) ; $ this -> setListRoute ( $ route ) ; } return $ this -> listRoute ; }
Retrieves list route
1,643
public function getCreateTemplate ( ) { if ( null === $ this -> createTemplate ) { $ template = rtrim ( $ this -> getTemplatePrefix ( ) , '/' ) . '/' . $ this -> getCreateSuffix ( ) ; $ this -> setCreateTemplate ( $ template ) ; } return $ this -> createTemplate ; }
Retrieves create template
1,644
public function getReadTemplate ( ) { if ( null === $ this -> readTemplate ) { $ template = rtrim ( $ this -> getTemplatePrefix ( ) , '/' ) . '/' . $ this -> getReadSuffix ( ) ; $ this -> setReadTemplate ( $ template ) ; } return $ this -> readTemplate ; }
Retrieves read template
1,645
public function getUpdateTemplate ( ) { if ( null === $ this -> updateTemplate ) { $ template = rtrim ( $ this -> getTemplatePrefix ( ) , '/' ) . '/' . $ this -> getUpdateSuffix ( ) ; $ this -> setUpdateTemplate ( $ template ) ; } return $ this -> updateTemplate ; }
Retrieves update template
1,646
public function getDeleteTemplate ( ) { if ( null === $ this -> deleteTemplate ) { $ template = rtrim ( $ this -> getTemplatePrefix ( ) , '/' ) . '/' . $ this -> getDeleteSuffix ( ) ; $ this -> setDeleteTemplate ( $ template ) ; } return $ this -> deleteTemplate ; }
Retrieves delete template
1,647
public function getListTemplate ( ) { if ( null === $ this -> listTemplate ) { $ template = rtrim ( $ this -> getTemplatePrefix ( ) , '/' ) . '/' . $ this -> getListSuffix ( ) ; $ this -> setListTemplate ( $ template ) ; } return $ this -> listTemplate ; }
Retrieves list template
1,648
public function getFormTemplate ( ) { if ( null === $ this -> formTemplate ) { $ template = rtrim ( $ this -> getTemplatePrefix ( ) , '/' ) . '/' . $ this -> getFormSuffix ( ) ; $ this -> setFormTemplate ( $ template ) ; } return $ this -> formTemplate ; }
Retrieves form template
1,649
public function getAllInstalledPackages ( bool $ rescan = false ) : array { if ( ! $ rescan && ! empty ( self :: $ allInstalledPackages ) ) { return self :: $ allInstalledPackages ; } $ compiledFile = $ this -> pathHelper -> realize ( '{MELIOR_BASE}/Data/Persistent/Compiler/Packages/package.map' ) ; if ( ! $ rescan && is_file ( $ compiledFile ) ) { $ result = \ unserialize ( \ file_get_contents ( $ compiledFile ) ) ; } else { $ result = array_merge ( $ this -> getLibraries ( $ rescan ) , $ this -> getPlugins ( $ rescan ) , $ this -> getApplicationPackages ( $ rescan ) ) ; } self :: $ allInstalledPackages = $ result ; return $ result ; }
Returns all installed packages .
1,650
public function getPlugins ( bool $ rescan = false ) : array { if ( ! $ rescan && ! empty ( self :: $ plugins ) ) { return self :: $ plugins ; } $ compiledFile = $ this -> pathHelper -> realize ( '{MELIOR_BASE}/Data/Persistent/Compiler/Packages/plugin.map' ) ; if ( ! $ rescan && is_file ( $ compiledFile ) ) { $ result = \ unserialize ( \ file_get_contents ( $ compiledFile ) ) ; } else { $ path = $ this -> pathHelper -> realize ( '{MELIOR_BASE}/Packages/Plugins/' ) ; if ( ! is_dir ( $ path ) ) { $ result = [ ] ; } else { $ result = $ this -> readPackageFolder ( $ path ) ; } } self :: $ plugins = $ result ; return $ result ; }
Returns all installed arrays .
1,651
public function getLibraries ( bool $ rescan = false ) : array { if ( ! $ rescan && ! empty ( self :: $ libraries ) ) { return self :: $ libraries ; } $ compiledFile = $ this -> pathHelper -> realize ( '{MELIOR_BASE}/Data/Persistent/Compiler/Packages/library.map' ) ; if ( ! $ rescan && is_file ( $ compiledFile ) ) { $ result = \ unserialize ( \ file_get_contents ( $ compiledFile ) ) ; } else { $ result = [ ] ; $ path = $ this -> pathHelper -> realize ( '{MELIOR_BASE}/Packages/Library/' ) ; if ( ! is_dir ( $ path ) ) { return [ ] ; } foreach ( scandir ( $ path ) as $ entry ) { if ( $ entry === '.' || $ entry === '..' ) { continue ; } $ subpath = $ this -> pathHelper -> join ( $ path , $ entry ) ; $ result = array_merge ( $ result , $ this -> readPackageFolder ( $ subpath ) ) ; } } self :: $ libraries = $ result ; return $ result ; }
Returns all installed libraries .
1,652
protected function readPackageFolder ( string $ folder ) : array { $ packages = [ ] ; foreach ( scandir ( $ folder ) as $ path ) { if ( $ path === '.' || $ path === '..' ) { continue ; } $ fullPath = $ this -> pathHelper -> join ( $ folder , $ path ) ; if ( ! is_dir ( $ fullPath ) ) { continue ; } $ composerJson = $ this -> composerParser -> parse ( $ this -> pathHelper -> realize ( $ this -> pathHelper -> join ( $ fullPath , 'composer.json' ) ) ) ; $ packages [ $ fullPath ] = $ composerJson ; } return $ packages ; }
Reads and parses a package folder to an array .
1,653
public function show ( $ id ) { if ( $ id == 'me' ) $ id = Account :: findOrFail ( Authorizer :: getResourceOwnerId ( ) ) -> uuid -> uuid ; $ entity = UUID :: findOrFail ( $ id ) -> entity ; return ResourceController :: resolveController ( $ entity ) -> show ( $ entity ) ; }
Display the requested entity with all the specified fields
1,654
protected function guardForArrayOrTraversable ( $ data , $ dataName = 'Argument' , $ exceptionClass = 'Zend\Stdlib\Exception\InvalidArgumentException' ) { if ( ! is_array ( $ data ) && ! ( $ data instanceof Traversable ) ) { $ message = sprintf ( "%s must be an array or Traversable, [%s] given" , $ dataName , is_object ( $ data ) ? get_class ( $ data ) : gettype ( $ data ) ) ; throw new $ exceptionClass ( $ message ) ; } }
Verifies that the data is an array or Traversable
1,655
public function findConnection ( string $ connectionName ) { if ( empty ( $ connectionName ) ) { $ connection = reset ( $ this -> connections ) ; if ( $ connection === false ) return null ; } else { $ connection = ( $ this -> connections [ strtolower ( $ connectionName ) ] ?? null ) ; } return $ connection ; }
Find a connection based on name
1,656
public function addConnection ( \ Nofuzz \ Database \ PdoConnectionInterface $ connection ) { $ this -> connections [ strtolower ( $ connection -> getName ( ) ) ] = $ connection ; return $ connection ; }
Adds the Connection to the Pool
1,657
public static function from ( int $ min , int $ max , int $ step ) : self { return new self ( Size :: from ( $ min ) , Size :: from ( $ max ) , Size :: from ( $ step ) ) ; }
Make a new SizeRange from ints .
1,658
public function sizes ( ) : Generator { for ( $ s = clone $ this -> min ; $ s -> compare ( $ this -> max ) < 1 ; $ s = $ s -> add ( $ this -> step ) ) { yield $ s ; } }
Generator function for iterating over the range .
1,659
public function onDispatchController ( MvcEvent $ eventvent ) { $ controller = $ eventvent -> getTarget ( ) ; if ( $ controller instanceof \ JaztecAcl \ Controller \ AuthorizedController ) { $ controller -> checkAcl ( $ eventvent ) ; } }
Perform an ACL check when an AuthorizedController is dispatched .
1,660
public function onDispatchDirect ( Event $ event ) { $ object = $ event -> getParam ( 'object' ) ; $ method = $ event -> getParam ( 'rpc' ) -> getMethod ( ) ; if ( $ object instanceof \ JaztecAcl \ Direct \ AuthorizedDirectObject ) { if ( ! $ object -> checkAcl ( $ method ) ) { $ event -> stopPropagation ( true ) ; return $ object -> notAllowed ( ) ; } } }
Perform an ACL check when a AuthorizedDirectObject is dispatched .
1,661
protected function _get ( Zend_Config $ config , array $ parts ) { if ( ( $ key = array_shift ( $ parts ) ) !== null && isset ( $ config -> $ key ) ) { if ( $ config -> $ key instanceof Zend_Config ) { if ( count ( $ parts ) > 0 ) { return $ this -> _get ( $ config -> $ key , $ parts ) ; } return $ config -> $ key -> toArray ( ) ; } return $ config -> $ key ; } return null ; }
Descents into the configuration specified by the given path and returns the value if found .
1,662
public static function ensureExists ( $ path = null , $ mode = self :: DEFAULT_UNIX_CHMOD_DIRECTORIES , $ recursive = true ) { if ( is_null ( $ path ) ) { return null ; } if ( file_exists ( $ path ) && is_dir ( $ path ) ) { return true ; } return self :: create ( $ path , $ mode , $ recursive ) ; }
Build a directory with its whole hierarchy if necessary
1,663
public static function remove ( $ path = null , array & $ logs = array ( ) ) { if ( is_null ( $ path ) ) { return null ; } if ( file_exists ( $ path ) && is_dir ( $ path ) ) { if ( ! is_dir ( $ path ) || is_link ( $ path ) ) { if ( array_key_exists ( $ path , $ logs ) ) { return false ; } if ( unlink ( $ path ) ) { return true ; } else { $ logs [ $ path ] = sprintf ( 'Can not unlink file "%s".' , $ path ) ; } } $ ok = self :: purge ( $ path , $ logs ) ; if ( true === $ ok ) { if ( array_key_exists ( $ path , $ logs ) ) { return false ; } if ( rmdir ( $ path ) ) { return true ; } else { $ logs [ $ path ] = sprintf ( 'Can not remove directory "%s".' , $ path ) ; } } clearstatcache ( ) ; return $ ok ; } else { $ logs [ $ path ] = sprintf ( 'Directory "%s" not found.' , $ path ) ; } return false ; }
Remove a directory with its whole contents
1,664
public static function purge ( $ path = null , array & $ logs = array ( ) ) { if ( is_null ( $ path ) ) { return null ; } if ( file_exists ( $ path ) && is_dir ( $ path ) ) { $ iterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ path ) , \ RecursiveIteratorIterator :: SELF_FIRST | \ FilesystemIterator :: CURRENT_AS_FILEINFO | \ FilesystemIterator :: SKIP_DOTS ) ; foreach ( $ iterator as $ item ) { if ( in_array ( $ item -> getFilename ( ) , array ( '.' , '..' ) ) ) { continue ; } $ _path = $ item -> getRealpath ( ) ; if ( array_key_exists ( $ _path , $ logs ) ) { return false ; } if ( $ item -> isDir ( ) ) { if ( false === ( $ ok = self :: remove ( $ _path , $ logs ) ) ) { $ logs [ $ _path ] = sprintf ( 'Can not remove diretory "%s".' , $ _path ) ; } } else { if ( false === ( $ ok = File :: remove ( $ _path , $ logs ) ) ) { $ logs [ $ _path ] = sprintf ( 'Can not unlink file "%s".' , $ _path ) ; } } } clearstatcache ( ) ; return $ ok ; } else { $ logs [ $ path ] = sprintf ( 'Directory "%s" not found.' , $ path ) ; } return false ; }
Remove a directory contents but not the directory itself
1,665
public static function chmod ( $ path = null , $ mode = self :: DEFAULT_UNIX_CHMOD_DIRECTORIES , $ recursive = true , $ file_mode = self :: DEFAULT_UNIX_CHMOD_FILES , array & $ logs = array ( ) ) { if ( is_null ( $ path ) ) { return null ; } $ ok = false ; if ( file_exists ( $ path ) && is_dir ( $ path ) ) { if ( true !== ( $ ok = chmod ( $ path , Filesystem :: getOctal ( $ mode ) ) ) ) { $ logs [ ] = sprintf ( 'Can not change mode on directory "%s" (trying to set them on "%d").' , $ path , $ mode ) ; } if ( $ ok && true === $ recursive ) { $ iterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ path ) , \ RecursiveIteratorIterator :: SELF_FIRST | \ FilesystemIterator :: CURRENT_AS_FILEINFO | \ FilesystemIterator :: SKIP_DOTS ) ; foreach ( $ iterator as $ item ) { if ( in_array ( $ item -> getFilename ( ) , array ( '.' , '..' ) ) ) { continue ; } if ( $ item -> isDir ( ) ) { if ( true !== ( $ ok = chmod ( $ item , Filesystem :: getOctal ( $ mode ) ) ) ) { $ logs [ ] = sprintf ( 'Can not change mode on sub-directory "%s" (trying to set them on "%d").' , $ item , $ mode ) ; } } elseif ( $ item -> isFile ( ) && ! $ item -> isLink ( ) ) { if ( true !== ( $ ok = chmod ( $ item , Filesystem :: getOctal ( $ file_mode ) ) ) ) { $ logs [ ] = sprintf ( 'Can not change mode on file "%s" (trying to set them on "%d").' , $ item , $ file_mode ) ; } } } } clearstatcache ( ) ; } else { $ logs [ ] = sprintf ( 'Directory "%s" not found (can not change mode).' , $ path ) ; } return $ ok ; }
Change rights on a directory
1,666
protected function addConfigParameterNode ( ) { $ builder = new TreeBuilder ( ) ; $ node = $ builder -> root ( 'config' ) ; $ node -> treatTrueLike ( array ( 'form' => array ( 'type' => "ASF\WebsiteBundle\Form\Type\ConfigType" , 'name' => 'website_config_type' ) ) ) -> treatFalseLike ( array ( 'form' => array ( 'type' => "ASF\WebsiteBundle\Form\Type\ConfigType" , 'name' => 'website_config_type' ) ) ) -> addDefaultsIfNotSet ( ) -> children ( ) -> arrayNode ( 'form' ) -> addDefaultsIfNotSet ( ) -> children ( ) -> scalarNode ( 'type' ) -> defaultValue ( 'ASF\WebsiteBundle\Form\Type\ConfigType' ) -> end ( ) -> scalarNode ( 'name' ) -> defaultValue ( 'website_config_type' ) -> end ( ) -> arrayNode ( 'validation_groups' ) -> prototype ( 'scalar' ) -> end ( ) -> defaultValue ( array ( "Default" ) ) -> end ( ) -> end ( ) -> end ( ) -> end ( ) ; return $ node ; }
Add Website Config Entity Configuration
1,667
public function is_enabled ( ) { $ disabled = 'no' === $ this -> enabled ; return apply_filters ( 'woocommerce_email_enabled_' . $ this -> id , ! $ disabled , $ this -> object ) ; }
Detect if this is enabled .
1,668
public function get_content_html ( ) { return wc_get_template_html ( $ this -> template_html , [ 'order' => $ this -> object , 'email_heading' => $ this -> get_heading ( ) , 'sent_to_admin' => false , 'plain_text' => false , 'email' => $ this , ] ) ; }
Get content html .
1,669
public function get_content_plain ( ) { return wc_get_template_html ( $ this -> template_plain , [ 'order' => $ this -> object , 'email_heading' => $ this -> get_heading ( ) , 'sent_to_admin' => false , 'plain_text' => true , 'email' => $ this , ] ) ; }
Get content plain .
1,670
protected function setConfigPath ( ) { $ this -> configPath = $ this -> basePath . '/' . static :: $ configsSubdir ; $ pathList = $ this -> getBasePathList ( ) ; foreach ( $ pathList as $ path ) { $ confPath = $ path . '/' . static :: $ configsSubdir ; if ( is_dir ( $ confPath ) ) { $ this -> configPath = $ confPath ; break ; } } }
Set config path first exists in parents modules chain
1,671
protected function correctControllerNamespace ( ) { $ nsList = $ this -> getNamespaceList ( ) ; $ pathList = $ this -> getBasePathList ( ) ; foreach ( $ pathList as $ i => $ path ) { $ controllersPath = $ path . '/' . static :: $ controllersSubdir ; if ( is_dir ( $ controllersPath ) ) { $ this -> controllerNamespace = $ nsList [ $ i ] . "\\" . static :: $ controllersSubdir ; break ; } } }
Change controllers namespace to first exists in parents modules chain
1,672
public static function findModuleByNamespace ( $ moduleNamespace , $ findOnlyParent = true ) { $ result = null ; foreach ( static :: $ _modulesNs as $ class => $ nsList ) { foreach ( $ nsList as $ i => $ ns ) { if ( $ ns == $ moduleNamespace ) { if ( $ findOnlyParent && $ i == 0 ) { continue ; } if ( empty ( $ result ) ) { $ result = $ class ; } else { throw new Exception ( "Find duplicate namespace '{$moduleNamespace}' for modules '{$result}' and '{$class}'" ) ; } } } } return $ result ; }
Find in inheritance chains module s namespaces and return class of module - owner .
1,673
public static function fullId ( ) { $ module_id = false ; $ modules = Yii :: $ app -> loadedModules ; foreach ( $ modules as $ module ) { if ( $ module instanceof static ) { $ module_id = $ module -> getUniqueId ( ) ; break ; } } return $ module_id ; }
Find this module class from loaded modules and return it s full id .
1,674
public static function getModuleByUniqueId ( $ uniqueId ) { $ modules = Yii :: $ app -> loadedModules ; foreach ( $ modules as $ module ) { if ( $ module -> uniqueId == $ uniqueId ) return $ module ; } return false ; }
Find module by unique Id from loaded modules
1,675
protected function setModels ( $ config ) { foreach ( $ config as $ alias => $ className ) { $ this -> _models [ $ alias ] = $ className ; } }
Save models classnames with aliases geting from config
1,676
public function getModelClassname ( $ alias ) { if ( empty ( $ this -> _models [ $ alias ] ) ) { throw new Exception ( "Shared model '{$alias}' not found in configuration of module " . static :: className ( ) ) ; } return $ this -> _models [ $ alias ] ; }
Get model s class name by it s alias defined in module s config .
1,677
public function getDataModel ( $ alias , $ params = [ ] , $ config = [ ] ) { if ( ! empty ( $ this -> _models [ $ alias ] ) ) { $ model = Yii :: createObject ( $ this -> models [ $ alias ] , $ params ) ; if ( $ model instanceof DataModel ) { $ config [ 'module' ] = $ this ; Yii :: configure ( $ model , $ config ) ; $ model -> prepare ( ) ; } return $ model ; } throw new Exception ( "Shared model '{$alias}' not found in configuration of module " . static :: className ( ) ) ; }
Get object of data model by alias defined in module s config .
1,678
public static function model ( $ alias , $ params = [ ] , $ config = [ ] ) { $ module = static :: instance ( ) ; if ( ! empty ( $ module ) ) { return $ module -> getDataModel ( $ alias , $ params , $ config ) ; } }
Get data model by alias defined in module config .
1,679
protected function setAssets ( $ config ) { foreach ( $ config as $ alias => $ className ) { $ this -> _assets [ $ alias ] = $ className ; } }
Save assets classnames with aliases geting from config
1,680
public function getAssetClassname ( $ alias ) { if ( empty ( $ this -> _assets [ $ alias ] ) ) { throw new Exception ( "Asset '{$alias}' not found in configuration of module " . static :: className ( ) ) ; } return $ this -> _assets [ $ alias ] ; }
Get asset s class name by it s alias defined in module s config .
1,681
protected function setWidgets ( $ config ) { foreach ( $ config as $ alias => $ className ) { $ this -> _widgets [ $ alias ] = $ className ; } }
Save widgets classnames with aliases geting from config
1,682
public function getWidget ( $ alias , array $ params = [ ] ) { if ( empty ( $ this -> _widgets [ $ alias ] ) ) { throw new Exception ( "Shared widget '{$alias}' not found in configuration of module " . static :: className ( ) ) ; } $ widget = Yii :: createObject ( $ this -> _widgets [ $ alias ] , $ params ) ; return $ widget ; }
Get widget by it s alias defined in module s config .
1,683
public static function widgetClass ( $ alias ) { $ result = false ; $ module = static :: instance ( ) ; if ( ! empty ( $ module ) && ! empty ( $ module -> _widgets [ $ alias ] ) ) { $ config = $ module -> _widgets [ $ alias ] ; if ( is_string ( $ config ) ) { $ result = $ config ; } elseif ( ! empty ( $ config [ 'class' ] ) ) { $ result = $ config [ 'class' ] ; } else { throw new Exception ( "Shared widget '{$alias}' has wrong in configuration in module " . static :: className ( ) ) ; } } return $ result ; }
Get widget class by alias defined in module config .
1,684
public static function mkfolders ( $ path ) { $ exFolder = explode ( "/" , $ path ) ; $ curpath = "" ; if ( is_array ( $ exFolder ) ) foreach ( $ exFolder as $ key => $ value ) { if ( $ value && $ value != "." && $ value != ".." ) { $ curpath = $ curpath . "/" . $ value ; File :: mkfolder ( $ curpath ) ; } else if ( $ value == "." || $ value == ".." ) { $ curpath = $ value ; } } }
Create a folders if not exist a foler to final path this create each folder
1,685
public function dirList ( $ path ) { if ( is_dir ( $ path ) ) { $ folder = opendir ( $ path ) ; while ( $ file = readdir ( $ folder ) ) { if ( $ file == '.' || $ file == '..' ) continue ; $ rtn [ ] = $ file ; } closedir ( $ folder ) ; } return $ rtn ; }
return files and diretoris existing in given directory
1,686
public function CopyFile ( $ source_path , $ target_path , $ arr = null ) { $ filename = substr ( strrchr ( $ target_path , "/" ) , 1 ) ; $ filepath = substr ( $ target_path , 0 , - strlen ( $ filename ) ) ; if ( is_array ( $ arr ) ) { if ( $ arr [ "overwrite" ] == true && is_file ( $ target_path ) ) { $ filename = "_" . $ filename ; copy ( $ source_path , $ filepath . $ filename ) ; } else { copy ( $ source_path , $ target_path ) ; } } else { copy ( $ source_path , $ target_path ) ; } return $ filename ; }
Copy file from source folder to dest . foler with some options
1,687
public function readFileList ( $ path ) { $ open_file = opendir ( $ path ) ; while ( $ opendir = readdir ( $ open_file ) ) { if ( ( $ opendir != "." ) && ( $ opendir != ".." ) && is_file ( $ targetdir . "/" . $ opendir ) ) { $ fileArr [ ] = $ opendir ; } } closedir ( $ open_file ) ; return $ fileArr ; }
This method same as dirList but return only files
1,688
public function RemoveFiles ( $ source ) { if ( is_dir ( $ source ) ) { $ folder = opendir ( $ source ) ; while ( $ file = readdir ( $ folder ) ) { if ( $ file == '.' || $ file == '..' ) continue ; if ( is_dir ( $ source . '/' . $ file ) ) $ this -> RemoveFiles ( $ source . '/' . $ file ) ; else unlink ( $ source . '/' . $ file ) ; } closedir ( $ folder ) ; rmdir ( $ source ) ; } return 1 ; }
Remove all files and folders lower depth then a given folder action this means Remoing Folder
1,689
public function extfile ( $ path ) { $ rtn [ "fullfilename" ] = substr ( strrchr ( $ path , "/" ) , 1 ) ; $ rtn [ "ext" ] = substr ( strrchr ( $ path , "." ) , 1 ) ; $ rtn [ "filename" ] = substr ( $ rtn [ "fullfilename" ] , 0 , - ( strlen ( $ rtn [ "ext" ] ) + 1 ) ) ; return $ rtn ; }
extract filename and extension from filename
1,690
public static function xml ( string $ str ) : bool { $ initialSetting = libxml_use_internal_errors ( ) ; libxml_use_internal_errors ( true ) ; $ result = simplexml_load_string ( $ str ) !== false ; libxml_use_internal_errors ( $ initialSetting ) ; return $ result ; }
Determines whether the given string is in a valid XML format .
1,691
protected static function matchesPattern ( string $ haystack , string $ pattern , string $ encoding = null ) : bool { $ initialEncoding = mb_regex_encoding ( ) ; mb_regex_encoding ( $ encoding ? : utils \ Str :: encoding ( $ haystack ) ) ; $ result = mb_ereg_match ( $ pattern , $ haystack ) ; mb_regex_encoding ( $ initialEncoding ) ; return $ result ; }
Checks whether the given string matches the given pattern .
1,692
public static function receive ( $ payload , $ crypt = null ) { $ stream = self :: _get ( ) ; if ( ! is_object ( $ crypt ) ) $ stream -> setCrypt ( Crypt :: _get ( Config :: get ( 'xport' , 'crypt.key' ) , Config :: get ( 'xport' , 'crypt.iv' ) ) ) ; else $ stream -> setCrypt ( $ crypt ) ; $ stream -> setup ( $ payload ) ; return $ stream ; }
this function requires an LSS environment
1,693
protected static function injectObjectToArray ( array & $ injectedObjects , $ objectName , $ mock , $ index ) { if ( $ index === null ) { $ injectedObjects [ $ objectName ] = $ mock ; } else { $ injectedObjects [ $ objectName ] [ $ index ] = $ mock ; } }
This method will inject an object into a specified array .
1,694
protected static function getMock ( array & $ injectedObjects , $ countsArray , $ className ) { if ( ! isset ( $ injectedObjects [ $ className ] ) || ! $ injectedObjects [ $ className ] ) { return null ; } if ( ! is_array ( $ injectedObjects [ $ className ] ) ) { return $ injectedObjects [ $ className ] ; } $ currentCount = isset ( self :: $ usedMockCounts [ $ countsArray ] [ $ className ] ) ? self :: $ usedMockCounts [ $ countsArray ] [ $ className ] : - 1 ; ++ $ currentCount ; self :: $ usedMockCounts [ $ countsArray ] [ $ className ] = $ currentCount ; return $ injectedObjects [ $ className ] [ $ currentCount ] ; }
This method will determine if we should return a mock . If so we will return the mock if not we will return null .
1,695
public static function createNewObject ( $ className , $ args = null ) { $ mock = self :: getMock ( self :: $ injectedObjects , 'object' , $ className ) ; if ( $ mock !== null ) { return $ mock ; } if ( $ args === null ) { return new $ className ( ) ; } $ reflection = new ReflectionClass ( $ className ) ; return $ reflection -> newInstanceArgs ( $ args ) ; }
This method will create a new object . This helps make our framework more testable .
1,696
public static function createToken ( $ name = 'csrfToken' , $ validTime = null ) { if ( ! is_int ( $ validTime ) ) $ validTime = 60 * 60 * 24 ; $ csrfToken = Http :: getInstance ( ) -> session ( ) -> get ( $ name , null ) ; $ storeTime = Http :: getInstance ( ) -> session ( ) -> get ( $ name . 'Time' , 0 ) ; if ( ( ( $ validTime + $ storeTime ) <= time ( ) ) || empty ( $ csrfToken ) ) { Http :: getInstance ( ) -> session ( ) -> set ( $ name , self :: generateToken ( ) ) ; Http :: getInstance ( ) -> session ( ) -> set ( $ name . 'Time' , time ( ) ) ; } return Http :: getInstance ( ) -> session ( ) -> get ( 'csrfToken' ) ; }
Create new Csrf Token and save it in the session for validation .
1,697
public static function validateToken ( $ name = 'csrfToken' , $ token = null ) { if ( $ token === null ) $ token = Http :: getInstance ( ) -> request ( ) -> paramPost ( $ name ) ; if ( ! is_string ( $ token ) ) return false ; return hash_equals ( $ token , Http :: getInstance ( ) -> session ( ) -> get ( $ name ) ) ; }
Safely test if token is valid .
1,698
private function setData ( $ data ) { if ( is_string ( $ data ) ) { $ data = [ $ data ] ; } $ body = $ this -> getBody ( ) ; $ body -> rewind ( ) ; $ json = json_encode ( $ data ) ; if ( config ( 'system.debug' , false ) ) { $ json = jsonpp ( str_replace ( [ '\n' , '\\\\' , '\t' ] , [ "\n" , '\\' , "\t" ] , $ json ) ) ; } $ body -> write ( $ json ) ; if ( $ json === false ) { throw new \ RuntimeException ( json_last_error_msg ( ) , json_last_error ( ) ) ; } }
Define o corpo da resposta
1,699
public static function require ( string $ permission ) : bool { if ( empty ( $ permission ) ) { return true ; } return self :: $ user -> hasPermission ( $ permission ) ; }
check if current user has a permission