idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
55,800
public function getResult ( $ forObject ) { return isset ( $ this -> hash [ $ forObject ] ) ? $ this -> hash [ $ forObject ] : null ; }
Gets a result from the container for the given object . When getting results for a batch of requests provide the request object .
55,801
public function getSuccessful ( ) { $ results = [ ] ; foreach ( $ this -> hash as $ key ) { if ( ! ( $ this -> hash [ $ key ] instanceof \ Exception ) ) { $ results [ ] = $ this -> hash [ $ key ] ; } } return $ results ; }
Get an array of successful results .
55,802
public function getFailures ( ) { $ results = [ ] ; foreach ( $ this -> hash as $ key ) { if ( $ this -> hash [ $ key ] instanceof \ Exception ) { $ results [ ] = $ this -> hash [ $ key ] ; } } return $ results ; }
Get an array of failed results .
55,803
public function getIterator ( ) { $ results = [ ] ; foreach ( $ this -> hash as $ key ) { $ results [ ] = $ this -> hash [ $ key ] ; } return new \ ArrayIterator ( $ results ) ; }
Allows iteration over all batch result values .
55,804
public function offsetGet ( $ key ) { $ i = - 1 ; foreach ( $ this -> hash as $ obj ) { if ( $ key === ++ $ i ) { return $ this -> hash [ $ obj ] ; } } return null ; }
Allows access of the batch using a numerical array index .
55,805
protected function welcomeMessage ( ) { $ this -> comment ( '' ) ; $ this -> comment ( '**************************************************' ) ; $ this -> comment ( ' Welcome to HoneyComb CMS initial configuration!!!' ) ; $ this -> comment ( '**************************************************' ) ; $ this -> info ( '' ) ; }
Shows welcome message
55,806
private function configureDatabase ( ) { $ this -> comment ( "Database configuration:" ) ; $ db [ 'host' ] = $ this -> choice ( "Database hostname: " , [ 'localhost' , 'custom' ] , 0 ) ; $ db [ 'name' ] = $ this -> ask ( "Database name: " ) ; $ db [ 'username' ] = $ this -> ask ( "Database username: " ) ; $ db [ 'password' ] = $ this -> secret ( "Database password: " ) ; if ( ! $ this -> _connected ( $ db ) ) { $ this -> info ( '' ) ; $ this -> error ( 'Not connected to database' ) ; $ this -> info ( '' ) ; return $ this -> configureDatabase ( ) ; } $ this -> envData [ 'DB_HOST' ] = $ db [ 'host' ] ; $ this -> envData [ 'DB_DATABASE' ] = $ db [ 'name' ] ; $ this -> envData [ 'DB_USERNAME' ] = $ db [ 'username' ] ; $ this -> envData [ 'DB_PASSWORD' ] = $ db [ 'password' ] . "\n" ; $ this -> info ( '' ) ; $ this -> comment ( 'Database configured successfully!' ) ; $ this -> info ( '' ) ; }
Configure database settings
55,807
private function _connected ( array $ db ) { try { $ connection = mysqli_connect ( $ db [ 'host' ] , $ db [ 'username' ] , $ db [ 'password' ] , $ db [ 'name' ] ) ; return $ connection ? true : false ; } catch ( \ Exception $ e ) { return false ; } }
Checks if connected to db
55,808
private function configureMailSettings ( ) { $ this -> comment ( 'Configure mail driver settings' ) ; $ choice = $ this -> choice ( "Choose MAIL DRIVER. [log|mandrill|mailgun|sparkpost|set_up_later]" , [ 'log' , 'mailgun' , 'mandrill' , 'sparkpost' , 'set_up_later' ] , 0 ) ; switch ( $ choice ) { case 'log' : $ this -> envData [ 'MAIL_DRIVER' ] = 'log' ; break ; case 'mandrill' : $ this -> envData [ 'MAIL_DRIVER' ] = 'mandrill' ; $ this -> envData [ 'MANDRILL_SECRET' ] = $ this -> ask ( "Mandrill secret code: " ) . "\n\n" ; break ; case 'mailgun' : $ this -> envData [ 'MAIL_DRIVER' ] = 'mailgun' ; $ this -> envData [ 'MAILGUN_DOMAIN' ] = $ this -> ask ( "Mailgun domain: " ) ; $ this -> envData [ 'MAILGUN_SECRET' ] = $ this -> ask ( "Mailgun secret: " ) . "\n\n" ; break ; case 'sparkpost' : $ this -> envData [ 'MAIL_DRIVER' ] = 'sparkpost' ; $ this -> envData [ 'SPARKPOST_SECRET' ] = $ this -> ask ( "Sparkpost secret: " ) . "\n\n" ; break ; default : break ; } }
Configure mail driver settings
55,809
private function _createEnvFile ( ) { $ fileName = '.env' ; $ content = "" ; foreach ( $ this -> envData as $ key => $ value ) $ content .= "$key=$value\n" ; $ path = base_path ( $ fileName ) ; if ( file_put_contents ( $ path , $ content ) ) return true ; return false ; }
Function which creates . env file
55,810
static function addPassword ( \ Db \ Connection $ db , User $ user , $ password ) { if ( ! $ user ) { throw new \ InvalidArgumentException ( "No user provided." ) ; } $ q = $ db -> prepare ( "SELECT * FROM user_passwords WHERE user_id=? LIMIT 1" ) ; $ q -> execute ( array ( $ user -> getId ( ) ) ) ; if ( $ q -> fetch ( ) ) { throw new UserAlreadyExistsException ( "That account already has a password." ) ; } $ email = $ user -> getEmail ( ) ; if ( ! $ email ) { throw new UserSignupException ( "That account requires an email address to add a password." ) ; } else if ( ! is_valid_email ( $ email ) ) { throw new UserSignupException ( "That is not a valid email." ) ; } $ q = $ db -> prepare ( "INSERT INTO user_passwords SET user_id=?, password_hash=?" ) ; $ q -> execute ( array ( $ user -> getId ( ) , UserPassword :: hash ( $ password ) ) ) ; return true ; }
Add a password to the given account .
55,811
static function deletePasswords ( \ Db \ Connection $ db , User $ user ) { if ( ! $ user ) { throw new \ InvalidArgumentException ( "No user provided." ) ; } $ q = $ db -> prepare ( "DELETE FROM user_passwords WHERE user_id=?" ) ; $ q -> execute ( array ( $ user -> getId ( ) ) ) ; return true ; }
Delete all paswords for the given user .
55,812
static function changePassword ( \ Db \ Connection $ db , User $ user , $ password ) { self :: deletePasswords ( $ db , $ user ) ; return self :: addPassword ( $ db , $ user , $ password ) ; }
Change the given users password . Removes all existing passwords and then adds a new password .
55,813
protected function _setBlock ( $ block ) { if ( $ block !== null && ! ( $ block instanceof BlockInterface ) ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Invalid block' ) , null , null , $ block ) ; } $ this -> block = $ block ; }
Sets the block for this instance .
55,814
protected function add_plugin ( $ file ) { $ this -> plugins [ ] = $ file ; add_filter ( static :: FILTER_HOOK_ACTION_LINKS . plugin_basename ( $ file ) , [ $ this , 'change_action_links' ] ) ; }
Adds a filename to the list of plugins to toggle and sets up a filter callback for each plugin s action links
55,815
public function get ( $ key ) { if ( $ this -> willRemove ( $ key ) ) { return null ; } if ( true === $ this -> willChange ( $ key ) ) { return $ this -> getCurrent ( $ key ) ; } return $ this -> getOriginal ( $ key ) ; }
Gets the current value of an property .
55,816
public function calculateChangeSet ( ) { $ set = [ ] ; foreach ( $ this -> current as $ key => $ current ) { $ original = isset ( $ this -> original [ $ key ] ) ? $ this -> original [ $ key ] : null ; $ set [ $ key ] [ 'old' ] = $ original ; $ set [ $ key ] [ 'new' ] = $ current ; } foreach ( $ this -> remove as $ key ) { $ set [ $ key ] [ 'old' ] = $ this -> original [ $ key ] ; $ set [ $ key ] [ 'new' ] = null ; } ksort ( $ set ) ; return $ set ; }
Calculates any property changes .
55,817
protected function clearRemoval ( $ key ) { if ( false === $ this -> willRemove ( $ key ) ) { return $ this ; } $ key = array_search ( $ key , $ this -> remove ) ; unset ( $ this -> remove [ $ key ] ) ; $ this -> remove = array_values ( $ this -> remove ) ; return $ this ; }
Clears an property from the removal queue .
55,818
protected function clearChange ( $ key ) { if ( true === $ this -> willChange ( $ key ) ) { unset ( $ this -> current [ $ key ] ) ; } return $ this ; }
Clears an property as having been changed .
55,819
protected function getOriginal ( $ key ) { if ( isset ( $ this -> original [ $ key ] ) ) { return $ this -> original [ $ key ] ; } return null ; }
Gets the property s original value .
55,820
protected function getCurrent ( $ key ) { if ( isset ( $ this -> current [ $ key ] ) ) { return $ this -> current [ $ key ] ; } return null ; }
Gets the property s current value .
55,821
public function parse ( $ signature ) { $ this -> setName ( $ signature ) ; $ argumentsOptions = $ this -> extractArgumentsOptions ( $ signature ) ; foreach ( $ argumentsOptions as $ value ) { if ( substr ( $ value , 0 , 2 ) !== '--' ) { $ input = new Argument ( $ value ) ; } else { $ input = new Option ( trim ( $ value , '--' ) ) ; } $ this -> command -> addInput ( $ input -> parse ( ) ) ; } }
Parse the command signature .
55,822
protected function extractArgumentsOptions ( $ signature ) { preg_match_all ( '/{(.*?)}/' , $ signature , $ argumentsOption ) ; return array_map ( function ( $ item ) { return trim ( $ item , '{}' ) ; } , $ argumentsOption [ 1 ] ) ; }
Extract arguments and options from signature .
55,823
public static function normalizeExpireAt ( $ ttl ) { self :: checkTtlType ( $ ttl ) ; if ( is_int ( $ ttl ) ) { return time ( ) + $ ttl ; } if ( $ ttl instanceof DateInterval ) { $ now = new DateTimeImmutable ; return $ now -> add ( $ ttl ) -> getTimestamp ( ) ; } return null ; }
Normalize timestamp for expire at
55,824
public static function normalizeTtl ( $ ttl ) { self :: checkTtlType ( $ ttl ) ; if ( is_int ( $ ttl ) ) { return $ ttl ; } if ( $ ttl instanceof DateInterval ) { $ now = new DateTimeImmutable ; return $ now -> add ( $ ttl ) -> getTimestamp ( ) - $ now -> getTimestamp ( ) ; } return null ; }
Normalize timestamp for TTL
55,825
public function path ( ) { $ data = [ 'year' => $ this -> created_at -> format ( 'Y' ) , 'month' => $ this -> created_at -> format ( 'm' ) , 'day' => $ this -> created_at -> format ( 'd' ) , 'slug' => $ this -> getSlug ( ) ] ; return \ URL :: route ( 'post.view' , $ data ) ; }
Return the post s path .
55,826
public function metaKeywords ( ) { $ metaKeywords = $ this -> getMetaKeywords ( ) ; if ( ! $ metaKeywords && $ type = $ this -> getType ( ) ) { $ metaKeywords = $ type -> getMetaKeywords ( ) ; } if ( ! $ metaKeywords ) { $ metaKeywords = $ this -> getTags ( ) ; } return $ metaKeywords ; }
Return the combined meta keywords .
55,827
public function metaDescription ( ) { $ metaDescription = $ this -> getMetaDescription ( ) ; if ( ! $ metaDescription && $ type = $ this -> getType ( ) ) { $ metaDescription = $ type -> getMetaDescription ( ) ; } return $ metaDescription ; }
Return the combined meta description .
55,828
public function setFile ( $ filePath , $ type = self :: CONTENT_APP_STREAM , $ suggestedFileName = '' , $ disposition = 'attachment' , $ ignore_user_abort = false ) { $ this -> setHeaders ( $ type , $ suggestedFileName , $ disposition , $ ignore_user_abort ) ; $ this -> content = file_get_contents ( $ filePath ) ; return $ this ; }
Set the file to be sent .
55,829
public function setFileContents ( $ fileContents , $ type = self :: CONTENT_APP_STREAM , $ suggestedFileName = '' , $ disposition = 'attachment' , $ ignore_user_abort = false ) { $ this -> setHeaders ( $ type , $ suggestedFileName , $ disposition , $ ignore_user_abort ) ; $ this -> content = $ fileContents ; return $ this ; }
Set the file contents to be sent .
55,830
private function setHeaders ( $ type = self :: CONTENT_APP_STREAM , $ suggestedFileName = '' , $ disposition = 'attachment' , $ ignore_user_abort = false ) { $ this -> headers -> set ( 'Content-Type' , $ type ) ; $ this -> headers -> set ( 'Content-Disposition' , ( $ disposition ? : 'attachment' ) . '; filename=' . $ suggestedFileName ) ; ignore_user_abort ( $ ignore_user_abort ) ; return $ this ; }
Set the response headers .
55,831
private function resolveTemplateType ( $ templateType ) { if ( is_string ( $ templateType ) && ! $ templateType = $ this -> templateTypeLoader -> retrieve ( $ templateTypeName = $ templateType ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Given template type name is invalid, "%s" given.' , $ templateTypeName ) ) ; } if ( $ templateType instanceof TemplateTypeInterface ) { return $ templateType ; } throw new \ InvalidArgumentException ( sprintf ( '%s only supports template type names or template type objects, "%s" given.' , __CLASS__ , is_object ( $ templateType ) ? get_class ( $ templateType ) : $ templateType ) ) ; }
Resolve given template type name as TemplateType object .
55,832
public function putContents ( $ filename , $ data , $ flags = 0 , $ context ) { return file_put_contents ( $ filename , $ data , $ flags , $ context ) ; }
Facade for the file_put_contents function .
55,833
public function fileOpen ( $ filename , $ mode , $ use_include_path = false , $ context ) { return fopen ( $ filename , $ mode , $ use_include_path , $ context ) ; }
Facade for the fopen function .
55,834
private function getApiMethod ( $ from ) { $ method = sprintf ( 'retrieve%s' , Utility :: classify ( $ from ) ) ; if ( ! method_exists ( $ this -> apiClient , $ method ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Method %s does not exist on %s!' , $ method , get_class ( $ this -> apiClient ) ) ) ; } return $ method ; }
Returns the apiClient method for the specified parameters
55,835
private function handle ( Response $ response , $ count = false ) { $ responseData = json_decode ( $ response -> getContent ( ) , true ) ; if ( ! $ response -> isSuccessful ( ) ) { throw new \ RuntimeException ( $ response -> getContent ( ) ) ; } if ( true === $ count ) { switch ( $ responseData [ 'kind' ] ) { case 'youtube#playlistItemListResponse' : return ( int ) $ responseData [ 'pageInfo' ] [ 'totalResults' ] ; break ; default : throw new \ Exception ( 'unsupported count operation' ) ; break ; } } if ( isset ( $ responseData [ 'nextPageToken' ] ) ) { $ this -> nextPageToken = $ responseData [ 'nextPageToken' ] ; } else { $ this -> nextPageToken = null ; } return $ responseData [ 'items' ] ; }
Handles a response from the ApiClient
55,836
public function findFirstTag ( $ tagName ) { $ nodes = $ this -> findTags ( $ tagName ) ; return $ nodes -> length > 0 ? $ nodes -> item ( 0 ) : false ; }
Finds the first element with given tag name .
55,837
public static function fromWeb ( $ url , HttpClient $ http = null ) { $ http = $ http ? : new HttpClient ( ) ; $ request = $ http -> get ( $ url ) ; if ( ! $ request -> success ) { throw new \ RuntimeException ( sprintf ( 'The URL "%s" could not be loaded.' , $ url ) ) ; } return new static ( $ request -> data ) ; }
Loads HTML from webpage .
55,838
public static function fromFile ( $ filename ) { if ( ! is_file ( $ filename ) || ! is_readable ( $ filename ) ) { throw new \ LogicException ( sprintf ( 'The file "%s" does not exist or is not readable.' , $ filename ) ) ; } $ html = file_get_contents ( $ filename ) ; return new static ( $ html ) ; }
Loads HTML from file .
55,839
public function getTicks ( ) { $ collection = [ ] ; $ reader = $ this -> getReader ( ) ; foreach ( $ this -> getClassesToScan ( ) as $ class ) { foreach ( $ class -> getMethods ( ) as $ method ) { foreach ( $ reader -> getMethodAnnotations ( $ method ) as $ annotation ) { array_push ( $ collection , $ annotation -> ticks ) ; } } } return $ collection ; }
Convert the scanned annotations into ticks definitions .
55,840
protected function getClassesToScan ( ) { $ classes = [ ] ; foreach ( $ this -> scan as $ class ) { try { $ classes [ ] = new ReflectionClass ( $ class ) ; } catch ( \ Exception $ e ) { } } return $ classes ; }
Get all of the ReflectionClass instances in the scan path .
55,841
public static function path ( $ path , $ trailingSlash = true ) { $ path = str_replace ( [ '\\' , '/' ] , PHP_DS , $ path ) ; $ path = rtrim ( $ path , PHP_DS ) ; if ( $ trailingSlash ) { $ path .= PHP_DS ; } return $ path ; }
Normalize the path .
55,842
public function authorize ( $ payment , $ amount ) { $ error = false ; if ( $ amount > 0 ) { $ payment -> setAmount ( $ amount ) ; $ transaction = $ this -> _build ( $ payment , self :: TRANSACTION_PREAUTH ) ; $ response = $ this -> _send ( $ transaction ) ; $ payment -> setCcApproval ( $ response -> getReceiptId ( ) ) -> setLastTransId ( $ response -> getReceiptId ( ) ) -> setCcTransId ( $ response -> getTxnNumber ( ) ) -> setCcAvsStatus ( $ response -> getAuthCode ( ) ) -> setCcCidStatus ( $ response -> getResponseCode ( ) ) ; if ( $ response -> getResponseCode ( ) > 0 && $ response -> getResponseCode ( ) <= self :: ERROR_CODE_LIMIT ) { $ payment -> setStatus ( self :: STATUS_APPROVED ) ; } else if ( $ response -> getResponseCode ( ) > self :: ERROR_CODE_LIMIT && $ response -> getResponseCode ( ) < self :: ERROR_CODE_UPPER_LIMIT ) { $ error = $ this -> _errors [ $ response -> getResponseCode ( ) ] ; } else { $ error = 'Incomplete transaction.' ; } } else { $ error = 'Invalid amount for authorization.' ; } if ( $ error !== false ) { $ this -> _log ( $ error ) ; } return $ this ; }
Authorize a payment for future capture
55,843
public function capture ( $ payment , $ amount ) { $ error = false ; if ( $ amount > 0 ) { $ payment -> setAmount ( $ amount ) ; $ transaction = $ this -> _build ( $ payment , self :: TRANSACTION_COMPLETION ) ; $ response = $ this -> _send ( $ transaction ) ; if ( $ response -> getResponseCode ( ) > 0 && $ response -> getResponseCode ( ) <= self :: ERROR_CODE_LIMIT ) { $ payment -> setStatus ( self :: STATUS_SUCCESS ) ; } else if ( $ response -> getResponseCode ( ) > self :: ERROR_CODE_LIMIT && $ response -> getResponseCode ( ) < self :: ERROR_CODE_UPPER_LIMIT ) { $ error = $ this -> _errors [ $ response -> getResponseCode ( ) ] ; } else { $ error = 'Incomplete transaction.' ; } } else { $ error = 'Invalid amount for authorization.' ; } if ( $ error !== false ) { $ this -> _log ( $ error ) ; } return $ this ; }
Capture the authorized transaction for a specific order
55,844
public function _send ( $ transaction ) { $ storeId = $ this -> getConfigData ( 'store_id' ) ; $ apiToken = $ this -> getConfigData ( 'api_token' ) ; $ request = new mpgRequest ( $ transaction ) ; $ mpgHttpsPost = new mpgHttpsPost ( $ storeId , $ apiToken , $ request ) ; return $ mpgHttpsPost -> getMpgResponse ( ) ; }
Receive a moneris transaction object and send it to the moneris webservice
55,845
public function _build ( $ payment , $ type ) { $ order = $ payment -> getOrder ( ) ; $ billing = $ order -> getBillingAddress ( ) ; $ shipping = $ order -> getShippingAddress ( ) ; $ token = $ this -> getConfigData ( 'order_token' ) ; $ token = ( empty ( $ token ) ) ? "" : "-" . $ token ; $ transaction = array ( 'type' => $ type , 'order_id' => $ order -> getIncrementId ( ) . $ token , 'crypt_type' => self :: CRYPT_TYPE , ) ; switch ( $ type ) { case self :: TRANSACTION_PREAUTH : $ transaction = $ transaction + array ( 'cust_id' => $ billing -> getCustomerId ( ) , 'amount' => sprintf ( "%01.2f" , $ payment -> getAmount ( ) ) , 'pan' => $ this -> _cleanCC ( $ payment -> getCcNumber ( ) ) , 'expdate' => $ this -> _formatExpirationDate ( $ payment -> getCcExpYear ( ) , $ payment -> getCcExpMonth ( ) ) , 'cvd_value' => $ payment -> getCcCid ( ) , 'cvd_indicator' => 1 ) ; break ; case self :: TRANSACTION_COMPLETION : $ transaction = $ transaction + array ( 'comp_amount' => sprintf ( "%01.2f" , $ payment -> getAmount ( ) ) , 'txn_number' => $ payment -> getCcTransId ( ) , ) ; break ; case self :: TRANSACTION_VOID : $ transaction = $ transaction + array ( 'comp_amount' => sprintf ( "%01.2f" , $ payment -> getAmount ( ) ) , 'txn_number' => $ payment -> getCcTransId ( ) , ) ; break ; } return new mpgTransaction ( $ transaction ) ; }
Build a moneris transaction object the data of moneris Make sure the transaction object is the appropriate type for the current step .
55,846
public function handle ( ) { $ client = new \ Raven_Client ( \ Skeleton \ Error \ Config :: $ sentry_dsn ) ; if ( isset ( $ _SESSION ) ) { $ client -> extra_context ( [ 'session' => print_r ( $ _SESSION , true ) ] ) ; } $ client -> captureException ( $ this -> exception ) ; }
Handle an error with Sentry
55,847
private function mysqlConnectionSetup ( $ capsule ) { $ capsule -> addConnection ( [ 'driver' => 'mysql' , 'host' => config ( 'database.connection.mysql.host' ) , 'database' => config ( 'database.connection.mysql.database' ) , 'username' => config ( 'database.connection.mysql.username' ) , 'password' => config ( 'database.connection.mysql.password' ) , 'charset' => config ( 'database.connection.mysql.charset' ) , 'collation' => config ( 'database.connection.mysql.collation' ) , 'prefix' => config ( 'database.connection.mysql.prefix' ) ] ) ; }
To connect with mysql database
55,848
private function bootPaginator ( ) { Paginator :: currentPathResolver ( function ( ) { return url ( ) ; } ) ; Paginator :: currentPageResolver ( function ( $ pageName = 'page' ) { return request ( ) -> input ( $ pageName ) ; } ) ; }
To boot Paginator
55,849
public static function parseAPI ( BitRank $ bitrank , $ flag_data ) { $ flags = [ ] ; foreach ( $ flag_data as $ key => $ value ) { $ slug = isset ( $ value [ 'flag' ] ) ? $ value [ 'flag' ] : $ key ; switch ( self :: requireValue ( $ value , 'type' ) ) { case Flag :: TYPE_GOOD : $ type = Flag :: TYPE_GOOD ; break ; case Flag :: TYPE_NEUTRAL : $ type = Flag :: TYPE_NEUTRAL ; break ; case Flag :: TYPE_BAD : $ type = Flag :: TYPE_BAD ; break ; default : throw new InvalidDataException ( "Invalid type '$value[type]' returned for flag '$slug'" ) ; } switch ( self :: requireValue ( $ value , 'impact' ) ) { case Flag :: IMPACT_HIGH : $ impact = Flag :: IMPACT_HIGH ; break ; case Flag :: IMPACT_MEDIUM : $ impact = Flag :: IMPACT_MEDIUM ; break ; case Flag :: IMPACT_LOW : $ impact = Flag :: IMPACT_LOW ; break ; default : throw new InvalidDataException ( "Invalid impact '$value[impact]' returned for flag '$slug'" ) ; } $ flags [ $ slug ] = new Flag ( $ bitrank , $ slug , $ type , $ impact ) ; } return $ flags ; }
Parse API input to flags list
55,850
public function get ( $ code ) { foreach ( $ this -> getDbConnection ( ) -> fetchAll ( 'SELECT * from oauth_auth_code WHERE auth_code = :authCode AND expire_time > :ts' , [ 'authCode' => $ code , 'ts' => time ( ) ] ) as $ row ) { if ( $ row ) { return ( new AuthCodeEntity ( $ this -> server ) ) -> setRedirectUri ( $ row [ 'client_redirect_uri' ] ) -> setExpireTime ( $ row [ 'expire_time' ] ) -> setId ( $ row [ 'auth_code' ] ) ; } } return null ; }
Get the auth code
55,851
private function twigLoad ( string $ path ) : ? \ Twig_TemplateWrapper { try { return $ this -> twigEnv -> load ( $ path ) ; } catch ( TwigError $ exc ) { if ( defined ( 'WP_DEBUG' ) && WP_DEBUG ) { throw $ exc ; } } }
Load Template Data
55,852
protected function ensureDestinationPath ( array $ pathParts , CollectionBuilder $ stack ) { $ path = $ this -> destination ; while ( $ folder = array_shift ( $ pathParts ) ) { $ path .= '/' . $ folder ; if ( ! file_exists ( $ path ) ) { $ stack -> mkdir ( $ path ) ; } } return $ this ; }
Ensures a path in the destination folder exists . Creates it if not .
55,853
protected function waitForMySQLDatabaseByName ( $ database_name ) { return $ this -> retry ( 50 , function ( ) use ( $ database_name ) { $ this -> databases = $ this -> fetchMySQLDatabases ( ) ; $ database = $ this -> getMysqlDatabaseByName ( $ this -> databases , $ database_name ) ; return $ database [ 'status' ] == 'installed' ? $ database : null ; } ) ; }
Wait for MySQL database by name!
55,854
public function setAction ( $ action ) { if ( null !== $ action && ! is_string ( $ action ) ) { throw new Exception ( 'Invalid argument: $action must be a string or null' ) ; } $ this -> _action = $ action ; $ this -> _hrefCache = null ; return $ this ; }
Sets action name to use when assembling URL
55,855
public function setController ( $ controller ) { if ( null !== $ controller && ! is_string ( $ controller ) ) { throw new Exception ( 'Invalid argument: $controller must be a string or null' ) ; } $ this -> _controller = $ controller ; $ this -> _hrefCache = null ; return $ this ; }
Sets controller name to use when assembling URL
55,856
public function setModule ( $ module ) { if ( null !== $ module && ! is_string ( $ module ) ) { throw new Exception ( 'Invalid argument: $module must be a string or null' ) ; } $ this -> _module = $ module ; $ this -> _hrefCache = null ; return $ this ; }
Sets module name to use when assembling URL
55,857
public function setRoute ( $ route ) { if ( null !== $ route && ( ! is_string ( $ route ) || strlen ( $ route ) < 1 ) ) { throw new Exception ( 'Invalid argument: $route must be a non-empty string or null' ) ; } $ this -> _route = $ route ; $ this -> _hrefCache = null ; return $ this ; }
Sets route name to use when assembling URL
55,858
public function setResetParams ( $ resetParams ) { $ this -> _resetParams = ( bool ) $ resetParams ; $ this -> _hrefCache = null ; return $ this ; }
Sets whether params should be reset when assembling URL
55,859
public function setEncodeUrl ( $ encodeUrl ) { $ this -> _encodeUrl = ( bool ) $ encodeUrl ; $ this -> _hrefCache = null ; return $ this ; }
Sets whether href should be encoded when assembling URL
55,860
public function setScheme ( $ scheme ) { if ( null !== $ scheme && ! is_string ( $ scheme ) ) { require_once 'Zend/Navigation/Exception.php' ; throw new Exception ( 'Invalid argument: $scheme must be a string or null' ) ; } $ this -> _scheme = $ scheme ; return $ this ; }
Sets scheme to use when assembling URL
55,861
public static function get_between_versions ( $ package = 'project' , \ Datetime $ start_date = null , \ Datetime $ end_date = null ) { $ migrations = self :: get_by_package ( $ package ) ; foreach ( $ migrations as $ key => $ migration ) { if ( $ start_date !== null ) { if ( $ migration -> get_version ( ) <= $ start_date ) { unset ( $ migrations [ $ key ] ) ; continue ; } } if ( $ end_date !== null ) { if ( $ migration -> get_version ( ) >= $ end_date ) { unset ( $ migrations [ $ key ] ) ; continue ; } } } return $ migrations ; }
Get between versions
55,862
public static function get_by_version ( $ version ) { $ migrations = self :: get_all ( ) ; if ( strpos ( $ version , '/' ) === false ) { $ version = 'project/' . $ version ; } list ( $ package , $ version ) = explode ( '/' , $ version ) ; $ migrations = \ Skeleton \ Database \ Migration :: get_between_versions ( $ package ) ; foreach ( $ migrations as $ migration ) { if ( preg_match ( '@\\\\([\w]+)$@' , get_class ( $ migration ) , $ matches ) ) { $ classname = $ matches [ 1 ] ; } else { $ classname = get_class ( $ migration ) ; } if ( $ version == $ classname ) { return $ migration ; } } throw new \ Exception ( 'The specified version does not exists.' ) ; }
Get specific version
55,863
public function has ( $ path ) { $ target = & $ this -> all ; foreach ( explode ( '.' , $ path ) as $ key ) { if ( array_key_exists ( $ key , $ target ) ) { $ target = & $ target [ $ key ] ; } else return false ; } return true ; }
if contains return true .
55,864
public function initClient ( ) { $ client = new Client ( array ( 'base_url' => $ this -> getBaseUrl ( ) , 'stream' => false , 'http_errors' => false , ) ) ; $ client -> setDefaultOption ( 'exceptions' , false ) ; $ this -> setClient ( $ client ) ; }
Init Guzzle5 client with base url .
55,865
public function resolve ( $ connectionName ) { $ config = $ this -> databaseConfigs [ $ connectionName ] ; $ driver = $ config [ 'driver' ] ; return $ this -> factories [ $ driver ] -> build ( $ config ) ; }
Resolve a connection by using the appropriate factory
55,866
private function setUpLayout ( ) { if ( Layout :: filename ( ) ) { return ; } Layout :: filename ( 'layout' . $ this -> divisionPostfix . '.php' ) ; Layout :: addJsMgr ( 'layout' . ( $ this -> _division === '' ? '' : '_' . $ this -> _division ) ) ; Layout :: addCss ( 'layout' . $ this -> divisionPostfix . '.css' ) ; $ fileBaseName = $ this -> _module . '_' . $ this -> _method ; $ jsPath = $ this -> divisionPath . '/js/managers/' ; $ jsName = $ this -> divisionPrefix . $ fileBaseName ; $ fileName = MODULES . $ jsPath . $ jsName . '_mgr.js' ; if ( file_exists ( $ fileName ) ) { Layout :: addJsMgr ( $ jsName , MOD . $ jsPath ) ; } $ cssPath = $ this -> divisionPath . '/css/' ; $ cssName = $ this -> divisionPrefix . $ fileBaseName . '.css' ; $ fileName = MODULES . $ cssPath . $ cssName ; if ( file_exists ( $ fileName ) ) { Layout :: addCss ( $ cssName , MOD . $ cssPath ) ; } }
Prepare layout with automatically added consts js js - mgr css .
55,867
protected function repositoryURL ( $ file ) { if ( $ this -> isAGithubRepo ( $ remote = $ this -> remoteGithub ( $ file ) ) ) { return $ remote ; } $ this -> error ( "Sorry we could not find a valid Git URL for folder $file" ) ; die ( ) ; }
Repository URL .
55,868
protected function folderContainsValidGithubRepo ( $ folder ) { $ remote = $ this -> remoteGithub ( $ folder ) ; if ( $ this -> isAGithubRepo ( $ remote ) ) { return true ; } return false ; }
Folder contains a valid Github repo .
55,869
public function setHandlers ( ) { $ error = configItem ( 'error' ) ; if ( $ error == 0 ) { ini_set ( 'display_errors' , 0 ) ; error_reporting ( 0 ) ; } else if ( $ error == 2 ) { error_reporting ( 0 ) ; set_error_handler ( array ( $ this , 'captureNormal' ) ) ; set_exception_handler ( array ( $ this , 'captureException' ) ) ; register_shutdown_function ( array ( $ this , 'captureShutdown' ) ) ; } else if ( $ error == 1 ) { error_reporting ( E_ALL ) ; ini_set ( 'display_errors' , 1 ) ; } }
Sets the Error Handlers
55,870
private function updateMainComposer ( array $ mainComposer , array $ content , string $ composerKey ) : array { if ( ! isset ( $ content [ $ composerKey ] ) ) return $ mainComposer ; $ content = $ content [ $ composerKey ] ; foreach ( $ content as $ key => $ value ) if ( strpos ( $ key , 'interactivesolutions/honeycomb' ) === false && ! isset ( $ mainComposer [ $ composerKey ] [ $ key ] ) ) $ mainComposer [ $ composerKey ] [ $ key ] = $ value ; return $ mainComposer ; }
Updating main composer file for dependencies
55,871
public static function register ( Configurator $ configurator ) { $ configurator -> onCompile [ ] = function ( $ configurator , $ compiler ) { $ compiler -> addExtension ( 'rest' , new RestExtension ( ) ) ; } ; }
Register REST API extension
55,872
public function download ( $ owner , $ repo , $ ref ) { $ fs = $ this -> getFs ( ) ; $ pfs = $ this -> project -> getFiles ( ) ; $ rfs = $ this -> remote -> getFilesystem ( $ repo , $ owner , $ ref ) ; $ files = $ rfs -> allFiles ( $ this -> docPath ) ; $ files = Arr :: without ( $ files , [ $ this -> indexPath , $ this -> menuPath ] ) ; $ total = count ( $ files ) ; if ( ! $ rfs -> exists ( $ this -> indexPath ) ) { return $ this -> syncer -> log ( 'error' , 'syncRef could not find the index file' , [ $ this -> indexPath ] ) ; } if ( ! $ rfs -> exists ( $ this -> menuPath ) ) { return $ this -> syncer -> log ( 'error' , 'syncRef could not find the menu file' , [ $ this -> menuPath ] ) ; } foreach ( $ files as $ current => $ filePath ) { $ destPath = path_relative ( $ filePath , $ this -> docPath ) ; if ( $ rfs -> exists ( $ filePath ) ) { $ pfs -> put ( path_join ( $ ref , $ destPath ) , $ rfs -> get ( $ filePath ) ) ; } $ this -> getSyncer ( ) -> fire ( 'tick.file' , [ $ current , $ total , $ filePath , $ this -> syncer , $ this ] ) ; } $ pfs -> put ( path_join ( $ ref , 'index.md' ) , $ rfs -> get ( $ this -> indexPath ) ) ; $ pfs -> put ( path_join ( $ ref , 'menu.yml' ) , $ rfs -> get ( $ this -> menuPath ) ) ; return $ this ; }
Download the ref
55,873
public function initialize ( $ vendor , $ package , $ directory ) { if ( ! $ this -> files -> exists ( $ directory ) || ! $ this -> files -> isDirectory ( $ directory ) ) { throw new InvalidPathException ( "{$directory} does not exist or is not a valid directory." ) ; } $ packageComposer = new Package ; $ packageComposer -> setVendor ( $ vendor ) ; $ packageComposer -> setPackage ( $ package ) ; $ packageComposer -> setDescription ( 'Give your package template a good description' ) ; $ packageComposer -> setLicense ( user_config ( 'configuration.license' , '' ) ) ; $ packageComposer -> setAuthors ( user_config ( 'configuration.authors' , [ ] ) ) ; $ writer = new ConfigurationWriter ( $ packageComposer -> toArray ( ) ) ; $ writer [ 'config' ] = ( object ) [ 'vendor-dir' => '_newup_vendor' ] ; $ writer -> save ( $ directory . '/composer.json' ) ; $ this -> renderer -> setData ( 'package' , $ package ) ; $ this -> renderer -> setData ( 'vendor' , $ vendor ) ; $ packageClass = $ this -> renderer -> render ( 'template' ) ; if ( ! $ this -> files -> exists ( $ directory . '/_newup/' ) ) { $ this -> files -> makeDirectory ( $ directory . '/_newup/' ) ; } if ( $ this -> shouldCreateTemplateDirectory && $ this -> files -> exists ( $ directory . '/_template' ) == false ) { $ this -> files -> makeDirectory ( $ directory . '/_template' ) ; } $ this -> files -> put ( $ directory . '/_newup/Package.php' , $ packageClass ) ; }
Initializes a package template in the provided directory .
55,874
public function Auth ( ) { if ( ! $ this -> OpenID -> mode ) { $ this -> OpenID -> identity = $ this -> OpenIDURL ; $ this -> OpenID -> returnUrl = url ( '' ) . $ _SERVER [ 'REQUEST_URI' ] ; $ this -> RedirectTo ( $ this -> OpenID -> authUrl ( ) ) ; } elseif ( $ this -> OpenID -> mode == 'cancel' ) { return false ; } elseif ( $ this -> OpenID -> validate ( ) ) { $ steamid64 = str_replace ( 'http://steamcommunity.com/openid/id/' , '' , $ this -> OpenID -> identity ) ; if ( $ steamid64 ) { $ url = 'http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?' ; $ query = http_build_query ( [ 'key' => Config :: get ( 'sgtaziz.steamauth.SteamAPIKey' ) , 'steamids' => $ steamid64 , ] ) ; $ json = file_get_contents ( $ url . $ query ) ; $ json = json_decode ( $ json , true ) ; $ user = $ json [ 'response' ] [ 'players' ] [ 0 ] ; $ user = json_decode ( json_encode ( $ user ) ) ; return $ user ; } } return false ; }
Check for Steam Authorization
55,875
public function transform ( SplFileInfo $ file ) { try { $ contentFile = $ this -> fileToContentFile -> transform ( $ file ) ; $ contentItem = $ this -> buildContentItem ( $ contentFile ) ; return $ contentItem ; } catch ( \ Exception $ e ) { throw new TransformationFailure ( $ e -> getMessage ( ) , 0 , $ e , $ file -> getRealPath ( ) ) ; } }
Transforms a file into a ContentItem
55,876
protected function getView ( Entity $ entity , array $ params = [ ] ) { switch ( true ) { case $ entity instanceof ContentItem : $ template = $ entity -> isIndex ( ) ? 'index.twig' : 'entry.twig' ; $ params [ 'entry' ] = $ entity ; break ; case $ entity instanceof Taxonomy : $ template = 'taxonomy.twig' ; $ params [ 'taxonomy' ] = $ entity ; break ; case $ entity instanceof Term : $ template = 'term.twig' ; $ params [ 'term' ] = $ entity ; break ; default : throw new \ LogicException ( 'Cannot render entity of type ' . get_class ( $ entity ) ) ; } return new View ( $ template , $ params ) ; }
Determines what template should be used to render the view . Template is determined by the type of entity .
55,877
protected function _GetAuthorizeUrl ( iApiCommand $ command ) { $ serverUrl = $ this -> _getServerUrlEndpoints ( $ command ) ; $ authUrl = \ Poirot \ Http \ appendQuery ( $ serverUrl , \ Poirot \ Http \ buildQueryString ( iterator_to_array ( $ command ) ) ) ; $ response = new Response ( $ authUrl ) ; return $ response ; }
Get Authorize Url By Argument Specified
55,878
function _Token ( iApiCommand $ command ) { $ headers = [ ] ; $ args = iterator_to_array ( $ command ) ; if ( array_key_exists ( 'client_id' , $ args ) && array_key_exists ( 'client_secret' , $ args ) ) { $ headers [ 'Authorization' ] = 'Basic ' . base64_encode ( $ args [ 'client_id' ] . ':' . $ args [ 'client_secret' ] ) ; unset ( $ args [ 'client_id' ] ) ; unset ( $ args [ 'client_secret' ] ) ; } $ url = $ this -> _getServerUrlEndpoints ( $ command ) ; $ response = $ this -> _sendViaCurl ( 'POST' , $ url , $ args , $ headers ) ; return $ response ; }
Request Grant Token
55,879
public function isRedirect ( ) { $ request = $ this -> request -> getData ( ) ; $ response = $ this -> getData ( ) ; return $ request [ 'opcode' ] === 0 && $ response [ 'extended_status' ] === '3DSECURE' ; }
Does the response require a redirect?
55,880
public function getTitle ( ) { $ node = $ this -> html -> findFirstTag ( 'title' ) ; return $ node ? trim ( $ node -> nodeValue ) : null ; }
Gets the title of the webpage .
55,881
public function getDescription ( ) { $ nodes = $ this -> html -> findTags ( 'meta' ) ; foreach ( $ nodes as $ node ) { if ( strtolower ( $ node -> getAttribute ( 'name' ) ) == 'description' ) { return trim ( $ node -> getAttribute ( 'content' ) ) ; } } return null ; }
Gets the description of the webpage .
55,882
public function getImages ( ) { $ images = array ( ) ; $ nodes = $ this -> html -> findTags ( 'img' ) ; foreach ( $ nodes as $ node ) { $ source = trim ( $ node -> getAttribute ( 'src' ) ) ; if ( empty ( $ source ) ) { continue ; } $ url = $ this -> getAbsoluteUrl ( $ source ) ; $ size = $ this -> getImageSize ( $ url ) ; if ( is_array ( $ size ) ) { list ( $ width , $ height ) = $ size ; } else { continue ; } if ( $ this -> isImageAccepted ( $ url , $ width , $ height ) ) { $ images [ ] = array ( 'url' => $ url , 'width' => $ width , 'height' => $ height , 'area' => ( $ width * $ height ) ) ; } } return $ images ; }
Gets the images of the webpage .
55,883
protected function getAbsoluteUrl ( $ href ) { if ( preg_match ( '#^(https?|ftps?)://#' , $ href ) ) { return $ href ; } elseif ( substr ( $ href , 0 , 2 ) == '//' ) { return parse_url ( $ this -> baseUrl , PHP_URL_SCHEME ) . ':' . $ href ; } elseif ( $ href [ 0 ] == '/' ) { return $ this -> baseUrl . $ href ; } else { return $ this -> localUrl . '/' . $ href ; } }
Transforms the given URL to an absolute URL .
55,884
protected function getImageSize ( $ url ) { $ request = $ this -> http -> get ( $ url , [ 'Range' => 'bytes=0-32768' ] ) ; if ( ! $ request -> success ) { return false ; } return getimagesizefromstring ( $ request -> data ) ; }
Returns the size of an image .
55,885
public function encode ( $ data ) : string { $ encoded = \ json_encode ( $ data , \ JSON_UNESCAPED_SLASHES | \ JSON_UNESCAPED_UNICODE ) ; if ( \ json_last_error ( ) !== JSON_ERROR_NONE ) { throw new EncodingException ( \ json_last_error_msg ( ) ) ; } return $ encoded ; }
Creates JSON string from provided data
55,886
public function decode ( string $ json ) : array { $ decoded = \ json_decode ( $ json , true ) ; if ( \ json_last_error ( ) !== JSON_ERROR_NONE ) { throw new DecodingException ( \ json_last_error_msg ( ) , \ json_last_error ( ) ) ; } return $ decoded ; }
Decodes JSON string into an associative array
55,887
public function base64UrlDecode ( string $ data ) : string { return \ base64_decode ( \ str_pad ( \ strtr ( $ data , '-_' , '+/' ) , \ strlen ( $ data ) % 4 , '=' , \ STR_PAD_RIGHT ) ) ; }
Decodes base64url string
55,888
public function getLoaders ( ) { $ loaders = array ( ) ; foreach ( $ this -> validators as $ validator ) { $ loaders [ $ validator -> getName ( ) ] = $ validator -> getLoader ( ) ; } return $ loaders ; }
Retrieve the populated loaders .
55,889
public function getClassMap ( ) { $ classMap = new ClassMap ( ) ; $ duplicates = array ( ) ; foreach ( $ this -> validators as $ validator ) { $ validatorName = $ validator -> getName ( ) ; $ partialClassMap = $ validator -> getClassMap ( ) ; foreach ( $ partialClassMap as $ class => $ file ) { try { $ classMap -> add ( $ class , $ file ) ; $ duplicates [ $ class ] [ $ validatorName ] = $ file ; } catch ( ClassAlreadyRegisteredException $ exception ) { $ duplicates [ $ class ] [ $ validatorName ] = $ file ; } } } foreach ( $ duplicates as $ class => $ files ) { if ( count ( $ files ) === 1 ) { continue ; } $ this -> report -> error ( new ClassAddedMoreThanOnceViolation ( implode ( ', ' , array_keys ( $ files ) ) , $ class , $ files ) ) ; } return $ classMap ; }
Retrieve a class map containing all the class maps from all registered validators .
55,890
public function with ( $ iteration ) { return $ this -> fold ( array ( ) , function ( $ a , $ f ) use ( $ iteration ) { $ iteration ( $ f ) ; if ( ! $ f -> isFile ( ) ) { $ f -> contents ( ) ; } $ a [ ] = $ f ; return $ a ; } ) ; }
Like fold but with no start value or return .
55,891
public function moveUpAction ( Request $ request ) { $ context = $ this -> loadContext ( $ request ) ; $ resource = $ context -> getResource ( ) ; $ this -> isGranted ( 'EDIT' , $ resource ) ; $ repo = $ this -> getRepository ( ) ; $ repo -> moveUp ( $ resource , 1 ) ; return $ this -> redirectToReferer ( $ this -> generateUrl ( $ this -> config -> getRoute ( 'list' ) , $ context -> getIdentifiers ( ) ) ) ; }
Decrement the position .
55,892
public function moveDownAction ( Request $ request ) { $ context = $ this -> loadContext ( $ request ) ; $ resource = $ context -> getResource ( ) ; $ this -> isGranted ( 'EDIT' , $ resource ) ; $ repo = $ this -> getRepository ( ) ; $ repo -> moveDown ( $ resource , 1 ) ; return $ this -> redirectToReferer ( $ this -> generateUrl ( $ this -> config -> getRoute ( 'list' ) , $ context -> getIdentifiers ( ) ) ) ; }
Increment the position .
55,893
public function newChildAction ( Request $ request ) { $ this -> isGranted ( 'CREATE' ) ; $ context = $ this -> loadContext ( $ request ) ; $ resourceName = $ this -> config -> getResourceName ( ) ; $ resource = $ context -> getResource ( $ resourceName ) ; $ child = $ this -> createNewFromParent ( $ context , $ resource ) ; if ( 0 < strlen ( $ referer = $ request -> headers -> get ( 'referer' ) ) ) { $ cancelPath = $ referer ; } else { $ cancelPath = $ this -> generateResourcePath ( $ request ) ; } $ form = $ this -> createForm ( $ this -> config -> getFormType ( ) , $ child , [ 'action' => $ this -> generateUrl ( $ this -> config -> getRoute ( 'new_child' ) , $ context -> getIdentifiers ( true ) ) , 'method' => 'POST' , 'attr' => [ 'class' => 'form-horizontal form-with-tabs' , ] , 'admin_mode' => true , '_redirect_enabled' => true , ] ) -> add ( 'actions' , 'form_actions' , [ 'buttons' => [ 'saveAndList' => [ 'type' => 'submit' , 'options' => [ 'button_class' => 'primary' , 'label' => 'ekyna_core.button.save_and_list' , 'attr' => [ 'icon' => 'list' , ] , ] , ] , 'save' => [ 'type' => 'submit' , 'options' => [ 'button_class' => 'primary' , 'label' => 'ekyna_core.button.save' , 'attr' => [ 'icon' => 'ok' , ] , ] , ] , 'cancel' => [ 'type' => 'button' , 'options' => [ 'label' => 'ekyna_core.button.cancel' , 'button_class' => 'default' , 'as_link' => true , 'attr' => [ 'class' => 'form-cancel-btn' , 'icon' => 'remove' , 'href' => $ cancelPath , ] , ] , ] , ] , ] ) ; $ form -> handleRequest ( $ this -> getRequest ( ) ) ; if ( $ form -> isValid ( ) ) { $ this -> getRepository ( ) -> persistAsLastChildOf ( $ child , $ resource ) ; $ event = $ this -> getOperator ( ) -> create ( $ child ) ; $ event -> toFlashes ( $ this -> getFlashBag ( ) ) ; if ( ! $ event -> hasErrors ( ) ) { if ( $ form -> get ( 'actions' ) -> get ( 'saveAndList' ) -> isClicked ( ) ) { $ redirectPath = $ this -> generateResourcePath ( $ resource , 'list' ) ; } elseif ( null === $ redirectPath = $ form -> get ( '_redirect' ) -> getData ( ) ) { $ redirectPath = $ this -> generateResourcePath ( $ child ) ; } return $ this -> redirect ( $ redirectPath ) ; } } return $ this -> render ( $ this -> config -> getTemplate ( 'new_child.html' ) , $ context -> getTemplateVars ( [ 'child' => $ child , 'form' => $ form -> createView ( ) ] ) ) ; }
Creates a child resource .
55,894
public function createNewFromParent ( Context $ context , $ parent ) { $ resource = $ this -> createNew ( $ context ) ; $ resource -> setParent ( $ parent ) ; return $ resource ; }
Creates a new resource and configure it regarding to the parent .
55,895
function html ( $ string , $ options = array ( ) ) { static $ defaultCharset = false ; $ defaultCharset = 'UTF-8' ; $ default = array ( 'remove' => false , 'charset' => $ defaultCharset , 'quotes' => ENT_QUOTES , 'double' => true ) ; $ options = array_merge ( $ default , $ options ) ; if ( $ options [ 'remove' ] ) { $ string = strip_tags ( $ string ) ; } return htmlentities ( $ string , $ options [ 'quotes' ] , $ options [ 'charset' ] , $ options [ 'double' ] ) ; }
Returns given string safe for display as HTML . Renders entities .
55,896
protected function strip_images ( $ str ) { $ str = preg_replace ( '/(<a[^>]*>)(<img[^>]+alt=")([^"]*)("[^>]*>)(<\/a>)/i' , '$1$3$5<br />' , $ str ) ; $ str = preg_replace ( '/(<img[^>]+alt=")([^"]*)("[^>]*>)/i' , '$2<br />' , $ str ) ; $ str = preg_replace ( '/<img[^>]*>/i' , '' , $ str ) ; return $ str ; }
Strips image tags from output
55,897
protected function strip_tags ( ) { $ params = func_get_args ( ) ; $ str = $ params [ 0 ] ; for ( $ i = 1 , $ count = count ( $ params ) ; $ i < $ count ; $ i ++ ) { $ str = preg_replace ( '/<' . $ params [ $ i ] . '\b[^>]*>/i' , '' , $ str ) ; $ str = preg_replace ( '/<\/' . $ params [ $ i ] . '[^>]*>/i' , '' , $ str ) ; } return $ str ; }
Strips the specified tags from output . First parameter is string from where to remove tags . All subsequent parameters are tags .
55,898
public function isSatisfiedBy ( UrlModel $ url ) : bool { if ( ( string ) $ url -> substring ( 0 , 2 ) === '//' ) { return true ; } return ! $ url -> matches ( '/^[a-zA-Z]*:?\/\//' ) ; }
Check if the given url has a scheme or not
55,899
protected function isFilesystemReadable ( $ path ) { if ( $ this -> getFilesystem ( ) -> isReadable ( ) ) { return true ; } else { return $ this -> setError ( Message :: get ( Message :: STR_FS_NONREADABLE , $ path ) , Message :: STR_FS_NONREADABLE ) ; } }
Check filesystem readable or not