idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
46,400
public function addOptions ( array $ options ) : Getopt { if ( ! empty ( $ this -> options ) ) { $ this -> options = array_merge ( $ this -> options , $ options ) ; } else { $ this -> options = $ options ; } return $ this ; }
Add short options
46,401
public static function hasUser ( ) { if ( ! ( Yii :: $ app instanceof Application ) ) { return false ; } if ( ! Yii :: $ app -> db -> getTableSchema ( User :: tableName ( ) ) ) { return false ; } try { $ identityClass = Yii :: $ app -> user -> identityClass ; } catch ( \ Exception $ e ) { $ identityClass = false ; } if ( ! $ identityClass ) { return false ; } return ! Yii :: $ app -> user -> isGuest ; }
We just check whether module is installed and user is logged in .
46,402
public static function StartsWith ( $ haystack , $ needle ) { $ length = static :: Length ( $ needle ) ; return substr ( $ haystack , 0 , $ length ) === $ needle ; }
Determine if the given string starts with the given substring .
46,403
public static function EndsWith ( $ haystack , $ needle ) { $ length = static :: Length ( $ needle ) ; return $ length === 0 || ( substr ( $ haystack , - $ length ) === $ needle ) ; }
Determine if the given string ends with the given substring .
46,404
public static function Ucfirst ( $ str ) { return function_exists ( 'ucfirst' ) ? ucfirst ( $ str ) : static :: Upper ( substr ( $ str , 0 , 1 ) ) . substr ( $ str , 1 ) ; }
Change string s first character uppercase .
46,405
private function parseCommands ( array $ json , string $ procedureName ) { $ factory = new CommandFactory ( $ this -> app ) ; $ errors = [ ] ; foreach ( $ json as $ commandString ) { $ plugin = explode ( ':' , $ commandString , 2 ) [ 0 ] ; if ( ! $ this -> app -> getContainer ( ) -> hasPlugin ( $ plugin ) ) { $ errors [ ] = "Plugin '$plugin' is required to run procedure '$procedureName'." ; continue ; } $ parsedCommands [ ] = $ factory -> create ( $ plugin , $ commandString ) ; } if ( ! empty ( $ errors ) ) { throw new PluginNotFoundException ( implode ( PHP_EOL , $ errors ) ) ; } return $ parsedCommands ; }
Create command classes from a json array
46,406
private function parseUntilFound ( string $ procedure ) { foreach ( $ this -> parsed as $ path => $ json ) { if ( $ this -> hasProcedure ( $ json , $ procedure ) ) return $ json ; } $ json = $ this -> findMostLikelyFile ( $ procedure ) ; if ( ! is_null ( $ json ) ) return $ json ; foreach ( $ this -> unparsedPaths ( ) as $ path ) { $ json = $ this -> parsePath ( $ path ) ; if ( $ this -> hasProcedure ( $ json , $ procedure ) ) return $ json ; } return null ; }
Parse paths until file containing the given procedure if found or there is nothing left to parse .
46,407
private function findMostLikelyFile ( string $ procedure ) { foreach ( $ this -> paths as $ path ) { $ filename = Strings :: afterLast ( $ path , '/' ) ; $ filenameWithoutExtension = Strings :: untilLast ( $ filename , '.' ) ; if ( $ procedure === $ filenameWithoutExtension ) { return $ filename ; } } return null ; }
Find the file that is most likely to contain the given procedure . Prioritizes files with the same name as the procedure .
46,408
protected function getQueryBuilder ( $ repositoryMethod ) { $ repository = $ this -> getDriver ( ) -> getDoctrineOrmEm ( ) -> getRepository ( $ this -> getDriver ( ) -> getEntityFqn ( ) ) ; $ repositoryMethods = $ this -> getDriver ( ) -> getEntityRepositorySearchableMethods ( ) ; if ( ! method_exists ( $ repository , $ repositoryMethods [ $ repositoryMethod ] ) ) { return $ repository -> createQueryBuilder ( $ this -> getDriver ( ) -> getEntityAlias ( ) ) ; } $ queryBuilder = $ repository -> { $ repositoryMethods [ $ repositoryMethod ] } ( ) ; if ( ! $ queryBuilder instanceof QueryBuilder ) { throw new ResourceException ( sprintf ( 'The method "%s" of repository class must be return a %s instance' , $ repositoryMethods [ $ repositoryMethod ] , '\Doctrine\ORM\QueryBuilder' ) ) ; } return $ queryBuilder ; }
Get the QueryBuilder instance .
46,409
public function setTimestamp ( $ timestamp ) { if ( ! $ timestamp instanceof \ DateTime ) { $ date = new \ DateTime ( ) ; $ date -> setTimestamp ( $ timestamp ) ; } else { $ date = $ timestamp ; } $ this -> header [ 'TIMESTAMP' ] = $ date -> format ( 'M d H:i:s' ) ; return $ this ; }
Set the timestamp of the message generation
46,410
public function formatNumberToHumanReadable ( $ number , $ precision = 0 , $ method = 'common' ) { if ( $ number >= 1000000 ) { $ value = $ number / 1000000 ; $ extension = 'M' ; } elseif ( $ number >= 1000 && $ number < 1000000 ) { $ value = $ number / 1000 ; $ extension = 'K' ; } else { $ value = $ number ; $ extension = '' ; } if ( 'common' == $ method ) { $ value = round ( $ value , $ precision ) ; } else { if ( 'ceil' != $ method && 'floor' != $ method ) { throw new \ RuntimeException ( 'The number_to_human_readable filter only supports the "common", "ceil", and "floor" methods.' ) ; } $ value = $ method ( $ value * pow ( 10 , $ precision ) ) / pow ( 10 , $ precision ) ; } return $ value . $ extension ; }
Format a large number into the closest million or thousand
46,411
protected function _styleElement ( ) { $ styleElementConfig = $ this -> gridConfig [ 'styleElement' ] ?? NULL ; if ( ! empty ( $ styleElementConfig ) ) { $ attributes = NULL ; $ sheet = Singleton :: class ( 'ZN\Hypertext\Sheet' ) ; $ style = Singleton :: class ( 'ZN\Hypertext\Style' ) ; foreach ( $ styleElementConfig as $ selector => $ attr ) { $ attributes .= $ sheet -> selector ( $ selector ) -> attr ( $ attr ) -> create ( ) ; } return $ style -> open ( ) . $ attributes . $ style -> close ( ) ; } return NULL ; }
Protected Style Element
46,412
protected function _transition ( $ transition ) { if ( ! $ this -> _canTransition ( $ transition ) ) { throw $ this -> _createCouldNotTransitionException ( $ this -> __ ( 'Cannot apply transition "%s"' , $ transition ) , null , null , $ transition ) ; } return $ this -> _applyTransition ( $ transition ) ; }
Applies a transition .
46,413
public function loadTemplate ( $ template ) { if ( ! $ this -> isLoaded ( $ identity = $ this -> findIdentity ( $ template ) ) ) { if ( ! $ this -> supports ( $ identity ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Unsupported template "%s".' , $ identity -> getName ( ) ) ) ; } $ this -> setLoaded ( $ identity , $ this -> getLoader ( ) -> load ( $ identity ) ) ; } return $ this -> getLoaded ( $ identity ) ; }
Try to load the given template
46,414
function now ( ) { if ( strtolower ( $ this -> timeReference ) == 'gmt' ) { $ now = time ( ) ; $ system_time = mktime ( gmdate ( "H" , $ now ) , gmdate ( "i" , $ now ) , gmdate ( "s" , $ now ) , gmdate ( "m" , $ now ) , gmdate ( "d" , $ now ) , gmdate ( "Y" , $ now ) ) ; if ( strlen ( $ system_time ) < 10 ) { $ system_time = time ( ) ; } return $ system_time ; } else { return time ( ) ; } }
Return current Unix timestamp or its GMT equivalent based on the time reference
46,415
function mdate ( $ date_format = '' , $ time = '' ) { if ( $ date_format == '' ) { $ date_format = $ this -> dateFormat ; } if ( $ time == '' ) { $ time = $ this -> now ( ) ; } return date ( $ date_format , $ time ) ; }
Return date based on the date format
46,416
function mdatetime ( $ time = '' , $ timezone = '' , $ datetime_format = '' ) { if ( $ datetime_format == '' ) { $ datetime_format = $ this -> dateFormat . ' ' . $ this -> timeFormat ; } if ( $ time == '' ) { $ time = 'now' ; } if ( $ timezone == '' ) { $ timezone = $ this -> timeZone ; } $ utc = new \ DateTimeZone ( $ timezone ) ; $ dt = new \ DateTime ( $ time , $ utc ) ; return $ dt -> format ( $ datetime_format ) ; }
Return date and time based on the datetime format
46,417
function get_first_date_last_month ( $ m = 1 ) { return $ this -> mdate ( $ this -> dateFormat , mktime ( 0 , 0 , 0 , $ this -> mdate ( "m" ) - $ m , 1 , $ this -> mdate ( "Y" ) ) ) ; }
Return first date of last month
46,418
function get_last_date_last_month ( $ m = 1 ) { return $ this -> mdate ( $ this -> dateFormat , mktime ( 24 , 0 , 0 , $ this -> mdate ( "m" ) - ( $ m - 1 ) , - 1 , $ this -> mdate ( "Y" ) ) ) ; }
Return last date of last month
46,419
function get_first_date_last_year ( $ y = 1 ) { return $ this -> mdate ( $ this -> dateFormat , mktime ( 0 , 0 , 0 , 1 , 1 , $ this -> mdate ( "Y" ) - $ y ) ) ; }
Return first date of last year
46,420
function get_last_date_last_year ( $ y = 1 ) { return $ this -> mdate ( $ this -> dateFormat , mktime ( 24 , 0 , 0 , 1 , - 1 , $ this -> mdate ( "Y" ) - ( $ y - 1 ) ) ) ; }
Return last date of last year
46,421
public function createNew ( string $ name , array $ tags ) : array { $ array = [ 'name' => $ name , 'tags' => $ tags ] ; return $ this -> sendPost ( sprintf ( '/profiles/%s/sources' , $ this -> userName ) , [ ] , $ array ) ; }
Creates a new source for the given username .
46,422
public function updateOne ( int $ sourceId , array $ tags , int $ otpCode = null , string $ ipaddr = '' ) : array { $ array = [ 'tags' => $ tags ] ; if ( $ otpCode !== null ) { $ array [ 'otpCode' ] = $ otpCode ; } return $ this -> sendPatch ( sprintf ( '/profiles/%s/sources/%s' , $ this -> userName , $ sourceId ) , [ ] , $ array ) ; }
Updates a source in the given profile .
46,423
public function setMin ( string $ min ) : Datetime { $ min = date ( $ this -> format , strtotime ( $ min ) ) ; $ this -> attributes [ 'min' ] = $ min ; return $ this -> addTest ( 'min' , function ( $ value ) use ( $ min ) { return $ value >= $ min ; } ) ; }
Set the minimum datetime .
46,424
public function setMax ( string $ max ) : Datetime { $ max = date ( $ this -> format , strtotime ( $ max ) ) ; $ this -> attributes [ 'max' ] = $ max ; return $ this -> addTest ( 'max' , function ( $ value ) use ( $ max ) { return $ value <= $ max ; } ) ; }
Set the maximum datetime .
46,425
public function generateInfoMetadata ( PackageEvent $ event ) { $ op = $ event -> getOperation ( ) ; $ package = $ op -> getJobType ( ) == 'update' ? $ op -> getTargetPackage ( ) : $ op -> getPackage ( ) ; $ installPath = $ this -> installationManager -> getInstallPath ( $ package ) ; if ( preg_match ( '/^drupal-/' , $ package -> getType ( ) ) ) { if ( preg_match ( '/^dev-/' , $ package -> getPrettyVersion ( ) ) ) { $ name = $ package -> getName ( ) ; $ project = preg_replace ( '/^.*\//' , '' , $ name ) ; $ version = preg_replace ( '/^dev-(.*)/' , $ this -> core . '.x-$1-dev' , $ package -> getPrettyVersion ( ) ) ; $ branch = preg_replace ( '/^([0-9]*\.x-[0-9]*).*$/' , '$1' , $ version ) ; $ datestamp = time ( ) ; $ this -> io -> write ( ' - Generating metadata for <info>' . $ name . '</info>' ) ; $ version = $ this -> computeRebuildVersion ( $ installPath , $ branch ) ? : $ version ; if ( $ this -> core == '7' ) { $ finder = new Finder ( ) ; $ finder -> files ( ) -> in ( $ installPath ) -> name ( '*.info' ) -> notContains ( 'datestamp =' ) ; foreach ( $ finder as $ file ) { file_put_contents ( $ file -> getRealpath ( ) , $ this -> generateInfoIniMetadata ( $ version , $ project , $ datestamp ) , FILE_APPEND ) ; } } else { $ finder = new Finder ( ) ; $ finder -> files ( ) -> in ( $ installPath ) -> name ( '*.info.yml' ) -> notContains ( 'datestamp:' ) ; foreach ( $ finder as $ file ) { file_put_contents ( $ file -> getRealpath ( ) , $ this -> generateInfoYamlMetadata ( $ version , $ project , $ datestamp ) , FILE_APPEND ) ; } } } } }
Inject metadata into all . info files for a given project .
46,426
protected function computeRebuildVersion ( $ installPath , $ branch ) { $ version = '' ; $ branchPreg = preg_quote ( $ branch ) ; $ process = new Process ( "cd $installPath; git describe --tags" ) ; $ process -> run ( ) ; if ( $ process -> isSuccessful ( ) ) { $ lastTag = strtok ( $ process -> getOutput ( ) , "\n" ) ; if ( preg_match ( '/^(?<drupalversion>' . $ branchPreg . '\.\d+(?:-[^-]+)?)(?<gitextra>-(?<numberofcommits>\d+-)g[0-9a-f]{7})?$/' , $ lastTag , $ matches ) ) { if ( isset ( $ matches [ 'gitextra' ] ) ) { $ version = $ matches [ 'drupalversion' ] . '+' . $ matches [ 'numberofcommits' ] . 'dev' ; } else { $ version = $ lastTag . '+0-dev' ; } } } return $ version ; }
Helper function to compute the rebulid version string for a project .
46,427
protected function generateInfoIniMetadata ( $ version , $ project , $ datestamp ) { $ core = preg_replace ( '/^([0-9]).*$/' , '$1.x' , $ version ) ; $ date = date ( 'Y-m-d' , $ datestamp ) ; $ info = <<<METADATA; Information add by drustack/composer-generate-metadata on {$date}core = "{$core}"project = "{$project}"version = "{$version}"datestamp = "{$datestamp}"METADATA ; return $ info ; }
Generate version information for . info files in ini format .
46,428
protected function generateInfoYamlMetadata ( $ version , $ project , $ datestamp ) { $ core = preg_replace ( '/^([0-9]).*$/' , '$1.x' , $ version ) ; $ date = date ( 'Y-m-d' , $ datestamp ) ; $ info = <<<METADATA# Information add by drustack/composer-generate-metadata on {$date}core: "{$core}"project: "{$project}"version: "{$version}"datestamp: "{$datestamp}"METADATA ; return $ info ; }
Generate version information for . info . yml files in YAML format .
46,429
public function equals ( FilePathInterface $ filePath ) : bool { return $ this -> getDrive ( ) === $ filePath -> getDrive ( ) && $ this -> isAbsolute ( ) === $ filePath -> isAbsolute ( ) && $ this -> getDirectoryParts ( ) === $ filePath -> getDirectoryParts ( ) && $ this -> getFilename ( ) === $ filePath -> getFilename ( ) ; }
Returns true if the file path equals other file path false otherwise .
46,430
public function getDirectory ( ) : FilePathInterface { return new self ( $ this -> myIsAbsolute , $ this -> myAboveBaseLevel , $ this -> myDrive , $ this -> myDirectoryParts , null ) ; }
Returns the directory of the file path .
46,431
public function getParentDirectory ( ) : ? FilePathInterface { if ( $ this -> myParentDirectory ( $ aboveBaseLevel , $ directoryParts ) ) { return new self ( $ this -> myIsAbsolute , $ aboveBaseLevel , $ this -> myDrive , $ directoryParts , null ) ; } return null ; }
Returns the parent directory of the file path or null if file path does not have a parent directory .
46,432
public function toAbsolute ( ) : FilePathInterface { if ( $ this -> myAboveBaseLevel > 0 ) { throw new FilePathLogicException ( 'File path "' . $ this -> __toString ( ) . '" can not be made absolute: Relative path is above base level.' ) ; } return new self ( true , $ this -> myAboveBaseLevel , $ this -> myDrive , $ this -> myDirectoryParts , $ this -> myFilename ) ; }
Returns the file path as an absolute path .
46,433
public function toRelative ( ) : FilePathInterface { return new self ( false , $ this -> myAboveBaseLevel , null , $ this -> myDirectoryParts , $ this -> myFilename ) ; }
Returns the file path as a relative path .
46,434
public function withFilePath ( FilePathInterface $ filePath ) : FilePathInterface { if ( ! $ this -> myCombine ( $ filePath , $ isAbsolute , $ aboveBaseLevel , $ directoryParts , $ filename , $ error ) ) { throw new FilePathLogicException ( 'File path "' . $ this -> __toString ( ) . '" can not be combined with file path "' . $ filePath -> __toString ( ) . '": ' . $ error ) ; } return new self ( $ isAbsolute , $ aboveBaseLevel , $ filePath -> getDrive ( ) ? : $ this -> getDrive ( ) , $ directoryParts , $ filename ) ; }
Returns a copy of the file path combined with another file path .
46,435
public static function isValid ( string $ filePath ) : bool { return self :: myFilePathParse ( DIRECTORY_SEPARATOR , $ filePath , function ( $ p , $ d , & $ e ) { return self :: myPartValidator ( $ p , $ d , $ e ) ; } ) ; }
Checks if a file path is valid .
46,436
public static function parse ( string $ filePath ) : FilePathInterface { if ( ! self :: myFilePathParse ( DIRECTORY_SEPARATOR , $ filePath , function ( $ p , $ d , & $ e ) { return self :: myPartValidator ( $ p , $ d , $ e ) ; } , null , $ isAbsolute , $ aboveBaseLevel , $ drive , $ directoryParts , $ filename , $ error ) ) { throw new FilePathInvalidArgumentException ( 'File path "' . $ filePath . '" is invalid: ' . $ error ) ; } return new self ( $ isAbsolute , $ aboveBaseLevel , $ drive , $ directoryParts , $ filename ) ; }
Parses a file path .
46,437
private static function myFilePathParse ( string $ directorySeparator , string $ path , callable $ partValidator , callable $ stringDecoder = null , ? bool & $ isAbsolute = null , ? int & $ aboveBaseLevel = null , ? string & $ drive = null , ? array & $ directoryParts = null , ? string & $ filename = null , ? string & $ error = null ) : bool { $ drive = null ; if ( self :: myIsWindows ( ) ) { $ driveAndPath = explode ( ':' , $ path , 2 ) ; if ( count ( $ driveAndPath ) === 2 ) { $ drive = $ driveAndPath [ 0 ] ; if ( ! self :: myDriveValidator ( $ drive , $ error ) ) { return false ; } $ drive = strtoupper ( $ drive ) ; $ path = $ driveAndPath [ 1 ] ; } } $ result = self :: myParse ( $ directorySeparator , DIRECTORY_SEPARATOR !== '\'' ? str_replace ( '/' , DIRECTORY_SEPARATOR , $ path ) : $ path , $ partValidator , $ stringDecoder , $ isAbsolute , $ aboveBaseLevel , $ directoryParts , $ filename , $ error ) ; if ( $ drive !== null && ! $ isAbsolute ) { $ error = 'Path can not contain drive "' . $ drive . '" and non-absolute path "' . $ path . '".' ; return false ; } return $ result ; }
Tries to parse a file path and returns the result or error text .
46,438
private static function myPartValidator ( string $ part , bool $ isDirectory , ? string & $ error ) : bool { if ( preg_match ( self :: myIsWindows ( ) ? '/[\0<>:*?"|]+/' : '/[\0]+/' , $ part , $ matches ) ) { $ error = ( $ isDirectory ? 'Part of directory' : 'Filename' ) . ' "' . $ part . '" contains invalid character "' . $ matches [ 0 ] . '".' ; return false ; } return true ; }
Validates a directory part name or a file name .
46,439
private static function myDriveValidator ( string $ drive , ? string & $ error ) : bool { if ( ! preg_match ( '/^[a-zA-Z]$/' , $ drive ) ) { $ error = 'Drive "' . $ drive . '" is invalid.' ; return false ; } return true ; }
Validates a drive .
46,440
public function load ( $ className ) { $ this -> _classFilename = $ className . '.php' ; $ this -> _includePaths = explode ( PATH_SEPARATOR , get_include_path ( ) ) ; $ classFound = null ; if ( strpos ( $ this -> _classFilename , '\\' ) !== false ) { $ classFound = $ this -> searchForBackslashNamespacedClass ( ) ; } elseif ( strpos ( $ this -> _classFilename , '_' ) !== false ) { $ classFound = $ this -> searchForUnderscoreNamespacedClass ( ) ; } else { $ classFound = $ this -> searchForNonNamespacedClass ( ) ; } return $ classFound ; }
This function is called by the PHP runtime to find and load a class for use . Users of this class should not call this function .
46,441
protected function searchForBackslashNamespacedClass ( ) { $ filename = $ this -> _classFilename ; foreach ( $ this -> _includePaths as $ includePath ) { $ className = str_replace ( '\\' , '/' , $ filename ) ; $ filePath = $ includePath . DIRECTORY_SEPARATOR . $ className ; if ( file_exists ( $ filePath ) == true ) { require ( $ filePath ) ; return true ; } } return false ; }
This function searches for classes that are namespaced using the modern standard method of class namespacing .
46,442
protected function searchForNonNamespacedClass ( ) { $ filename = $ this -> _classFilename ; foreach ( $ this -> _includePaths as $ includePath ) { $ filePath = $ includePath . DIRECTORY_SEPARATOR . $ filename ; if ( file_exists ( $ filePath ) == true ) { require ( $ filename ) ; return true ; } } return false ; }
This function searches for classes that are not namespaced at all .
46,443
protected function getEntityNamePlural ( ) { $ name = $ this -> getEntityNameSingular ( ) ; $ nameParts = Text :: camelCaseToSeparator ( $ name , '#' ) ; $ nameParts = explode ( '#' , $ nameParts ) ; $ lastPart = array_pop ( $ nameParts ) ; $ lastPart = ucfirst ( Text :: plural ( strtolower ( $ lastPart ) ) ) ; array_push ( $ nameParts , $ lastPart ) ; return lcfirst ( implode ( '' , $ nameParts ) ) ; }
Get the plural name of the entity
46,444
protected function getEntityNameSingular ( ) { $ names = explode ( '\\' , $ this -> getEntityClassName ( ) ) ; $ name = end ( $ names ) ; return lcfirst ( $ name ) ; }
Get entity singular name used on controller actions
46,445
protected function generateBasename ( ) { $ filename = md5 ( $ this -> image . $ this -> height . $ this -> width ) ; if ( isset ( static :: $ config [ 'default_extension' ] ) ) { $ extension = static :: $ config [ 'default_extension' ] ; } else { $ extension = pathinfo ( $ this -> image , PATHINFO_EXTENSION ) ; } return $ filename . '.' . $ extension ; }
Generate basename from the destiny file
46,446
protected function isCacheExpired ( $ destiny ) { $ cacheModified = filemtime ( $ destiny ) ; if ( $ this -> expiration !== null ) { return $ this -> expiration > $ cacheModified ; } return filemtime ( $ this -> image ) > $ cacheModified ; }
Is Expired cache of image?
46,447
public static function fromFile ( $ filename , $ width , $ height = 0 ) { $ urlizer = new Urlizer ( $ filename ) ; static :: configureUrlizer ( $ urlizer ) ; if ( strpos ( $ filename , '/' ) !== 0 ) { $ filename = $ urlizer -> getPublicFilename ( ) ; } try { $ thumb = new static ( $ filename , $ width , $ height ) ; } catch ( \ InvalidArgumentException $ e ) { if ( static :: $ config [ 'fallback' ] === null ) { throw $ e ; } return static :: $ config [ 'fallback' ] ; } $ basename = $ thumb -> generateBasename ( ) ; $ filename = $ urlizer -> buildThumbFilename ( $ basename ) ; $ thumb -> getCache ( $ filename ) ; return $ urlizer -> buildThumbUrl ( $ basename ) ; }
Returns the url from thumb based on filename
46,448
public static function fromUrl ( $ url , $ width , $ height = 0 ) { $ extension = pathinfo ( strtok ( $ url , '?' ) , PATHINFO_EXTENSION ) ; $ filename = sprintf ( '%s/thumb_%s.%s' , sys_get_temp_dir ( ) , md5 ( $ url ) , $ extension ) ; if ( ! file_exists ( $ filename ) && ! @ copy ( $ url , $ filename , static :: getStreamContextOptions ( ) ) ) { return static :: $ config [ 'fallback' ] ; } $ urlizer = new Urlizer ( ) ; static :: configureUrlizer ( $ urlizer ) ; $ thumb = new static ( $ filename , $ width , $ height ) ; $ basename = $ thumb -> generateBasename ( ) ; $ filename = $ urlizer -> buildThumbFilename ( $ basename ) ; $ thumb -> getCache ( $ filename ) ; return $ urlizer -> buildThumbUrl ( $ basename ) ; }
Get copy from external file url for make thumb
46,449
public static function image ( $ relative , array $ attributes = [ ] ) { $ attributes += [ 'alt' => null ] ; $ height = isset ( $ attributes [ 'height' ] ) ? $ attributes [ 'height' ] : 0 ; $ width = isset ( $ attributes [ 'width' ] ) ? $ attributes [ 'width' ] : 0 ; $ url = static :: url ( $ relative , $ width , $ height ) ; $ attributes [ 'src' ] = $ url ; $ attrs = [ ] ; foreach ( $ attributes as $ name => $ attr ) { $ attrs [ ] = "$name=\"{$attr}\"" ; } $ attrs = implode ( ' ' , $ attrs ) ; return "<img {$attrs} />" ; }
Returns the image tag with thumb based on attributes height and width
46,450
protected static function configureUrlizer ( Urlizer $ urlizer ) { $ path = isset ( static :: $ config [ 'public_path' ] ) ? static :: $ config [ 'public_path' ] : $ _SERVER [ 'DOCUMENT_ROOT' ] ; $ urlizer -> setPublicPath ( $ path ) ; if ( isset ( static :: $ config [ 'base_uri' ] ) ) { $ urlizer -> setBaseUrl ( static :: $ config [ 'base_uri' ] ) ; } $ urlizer -> setThumbFolder ( static :: $ config [ 'thumb_folder' ] ) ; }
Configure the \ PHPLegends \ Thumb \ Urlizer from global config
46,451
protected function _createData ( callable $ func ) : array { $ data = \ call_user_func ( $ func ) ; if ( ! \ is_array ( $ data ) && ! $ data instanceof \ Traversable ) { return [ ] ; } $ return = [ ] ; foreach ( $ data as $ key => $ value ) { $ return [ $ key ] = [ 'value' => $ value , 'expires' => null ] ; } return $ return ; }
Calls the creator function of the items of new cache pools and transforms it into our internal used structure .
46,452
public function index ( UrlParamsProcessor $ processor ) { $ this -> authorize ( 'readList' , User :: class ) ; $ processor -> addFilter ( new ArrayParser ( 'id' ) ) -> addFilter ( new StringParser ( 'email' ) , 'email' ) -> addFilter ( new StringParser ( 'name' ) ) -> addFilter ( new StringParser ( 'first_name' ) ) -> addFilter ( new StringParser ( 'last_name' ) ) -> addFilter ( new DateRangeParser ( 'created_at' ) ) -> addFilter ( new DateParser ( 'updated_at' ) ) -> process ( $ this -> request ) ; $ results = $ this -> repository -> getMany ( $ processor -> buildQueryBuilder ( ) ) ; $ results -> setPath ( apiUrl ( 'users' ) ) ; return new UserCollection ( $ results ) ; }
Display list of all users
46,453
public function update ( $ id ) { $ user = $ this -> repository -> getById ( $ id ) ; if ( ! $ user ) { return $ this -> errorNotFound ( ) ; } $ this -> authorize ( 'update' , $ user ) ; $ input = $ this -> validator -> bind ( 'name' , [ 'user_id' => $ user -> id ] ) -> bind ( 'email' , [ 'user_id' => $ user -> id ] ) -> validate ( 'update' ) ; $ user = dispatch_now ( new UpdateUser ( $ user , $ input ) ) ; return new UserResource ( $ user ) ; }
Updates the specified resource .
46,454
public function get ( $ class = null ) { $ class = $ this -> get_class ( $ class ) ; if ( isset ( $ this -> reflections [ $ class ] ) ) return $ this -> reflections [ $ class ] ; throw new ActiveRecordException ( "Class not found: $class" ) ; }
Get a cached ReflectionClass .
46,455
public function setWebHook ( $ url ) { $ this -> data -> notification = new stdClass ; $ this -> data -> notification -> webhook = new stdClass ; $ this -> data -> notification -> webhook -> url = $ url ; return $ this ; }
Set Web Hook URL
46,456
public function enableMerchantEmail ( ) { $ this -> data -> email = new stdClass ; $ this -> data -> email -> merchant = new stdClass ; $ this -> data -> email -> merchant -> enabled = true ; return $ this ; }
Enable merchant by email
46,457
public function disableMerchantEmail ( ) { $ this -> data -> email = new stdClass ; $ this -> data -> email -> merchant = new stdClass ; $ this -> data -> email -> merchant -> enabled = false ; return $ this ; }
Disable merchant by email
46,458
public function enableCustomerEmail ( ) { $ this -> data -> email = new stdClass ; $ this -> data -> email -> customer = new stdClass ; $ this -> data -> email -> customer -> enabled = true ; return $ this ; }
Enable customer receive payments emails
46,459
public function disableCustomerEmail ( ) { $ this -> data -> email = new stdClass ; $ this -> data -> email -> customer = new stdClass ; $ this -> data -> email -> customer -> enabled = false ; return $ this ; }
Disable customer receive payments emails
46,460
public static function boot ( ICms $ cms ) { $ iocContainer = $ cms -> getIocContainer ( ) ; $ iocContainer -> bind ( IIocContainer :: SCOPE_SINGLETON , IContentGroupRepository :: class , DbContentGroupRepository :: class ) ; $ iocContainer -> bind ( IIocContainer :: SCOPE_SINGLETON , ContentLoaderService :: class , ContentLoaderService :: class ) ; $ iocContainer -> bindCallback ( IIocContainer :: SCOPE_SINGLETON , ContentConfig :: class , function ( ) use ( $ cms ) : ContentConfig { $ definition = new ContentConfigDefinition ( ) ; static :: defineConfig ( $ definition ) ; return $ definition -> finalize ( ) ; } ) ; }
Boots and configures the package resources and services .
46,461
protected function flattenValues ( & $ values ) { array_walk ( $ values , function ( & $ value ) { if ( $ this -> isOrnamentModel ( $ value ) ) { $ value = $ value -> getPrimaryKey ( ) ; if ( is_array ( $ value ) ) { $ value = '(' . implode ( ', ' , $ value ) . ')' ; } } } ) ; }
Internal helper to flatten all values associated with an operation . This is mainly useful for being able to store models on foreign keys and automatically flatten them to the associated key during saving .
46,462
function DBug ( $ var = '' , $ die = false , $ forceType = '' , $ bCollapsed = false ) { if ( $ var === '' ) { return ; } if ( ! defined ( 'BDBUGINIT' ) ) { define ( "BDBUGINIT" , TRUE ) ; $ this -> initJSandCSS ( ) ; } $ arrAccept = array ( "array" , "object" , "xml" ) ; $ this -> bCollapsed = $ bCollapsed ; if ( in_array ( $ forceType , $ arrAccept ) ) $ this -> { "varIs" . ucfirst ( $ forceType ) } ( $ var ) ; else $ this -> checkType ( $ var ) ; if ( $ die ) { die ( ) ; } }
Dumps out variable in a nice format
46,463
private function varIsXmlResource ( $ var ) { $ xml_parser = xml_parser_create ( ) ; xml_parser_set_option ( $ xml_parser , XML_OPTION_CASE_FOLDING , 0 ) ; xml_set_element_handler ( $ xml_parser , array ( & $ this , "xmlStartElement" ) , array ( & $ this , "xmlEndElement" ) ) ; xml_set_character_data_handler ( $ xml_parser , array ( & $ this , "xmlCharacterData" ) ) ; xml_set_default_handler ( $ xml_parser , array ( & $ this , "xmlDefaultHandler" ) ) ; $ this -> makeTableHeader ( "xml" , "xml document" , 2 ) ; $ this -> makeTDHeader ( "xml" , "xmlRoot" ) ; $ bFile = ( ! ( $ fp = @ fopen ( $ var , "r" ) ) ) ? false : true ; if ( $ bFile ) { while ( $ data = str_replace ( "\n" , "" , fread ( $ fp , 4096 ) ) ) $ this -> xmlParse ( $ xml_parser , $ data , feof ( $ fp ) ) ; } else { if ( ! is_string ( $ var ) ) { echo $ this -> error ( "xml" ) . $ this -> closeTDRow ( ) . "</table>\n" ; return ; } $ data = $ var ; $ this -> xmlParse ( $ xml_parser , $ data , 1 ) ; } echo $ this -> closeTDRow ( ) . "</table>\n" ; }
if variable is an xml resource type
46,464
public function scalarTripleProduct ( Vector3D $ second , Vector3D $ third ) : float { return $ this -> dotProduct ( $ second -> crossProduct ( $ third ) ) ; }
Computes the scalar triple product of this and two other Vectors .
46,465
public function vectorTripleProduct ( Vector3D $ second , Vector3D $ third ) : Vector3D { return $ this -> crossProduct ( $ second -> crossProduct ( $ third ) ) ; }
Computes the vector triple product of this and two other Vectors .
46,466
private function readData ( ) { switch ( $ this -> fileType ) { case self :: TYPE_JSON : $ data = json_decode ( file_get_contents ( $ this -> readPath ) , true ) ; break ; default : $ data = require $ this -> readPath ; } return $ data ; }
Reading file data .
46,467
public function get ( $ key ) { $ key = is_array ( $ key ) ? $ key : [ $ key ] ; $ config = $ this -> data ; while ( $ key ) { $ k = array_shift ( $ key ) ; $ config = isset ( $ config [ $ k ] ) ? $ config [ $ k ] : [ ] ; } return $ config ; }
Gets data sub value .
46,468
public function remove ( $ key ) { $ key = is_array ( $ key ) ? $ key : [ $ key ] ; $ config = $ this -> data ; $ data = & $ config ; while ( $ key ) { $ k = array_shift ( $ key ) ; if ( ! $ key ) { unset ( $ config [ $ k ] ) ; break ; } $ config [ $ k ] = isset ( $ config [ $ k ] ) ? $ config [ $ k ] : [ ] ; $ config = & $ config [ $ k ] ; } $ this -> data = $ data ; return $ this -> save ( ) ; }
Removes key from data .
46,469
public function put ( $ data ) { $ this -> data = array_merge ( $ this -> data , $ data ) ; return $ this -> save ( ) ; }
Puts complete data into file .
46,470
public function ResponseClass ( $ Class ) { $ Code = ( string ) $ this -> ResponseStatus ; if ( is_null ( $ Code ) ) return FALSE ; if ( strlen ( $ Code ) != strlen ( $ Class ) ) return FALSE ; for ( $ i = 0 ; $ i < strlen ( $ Class ) ; $ i ++ ) if ( $ Class { $ i } != 'x' && $ Class { $ i } != $ Code { $ i } ) return FALSE ; return TRUE ; }
Check if the provided response matches the provided response type
46,471
public function CheckedComments ( ) { $ this -> DeliveryType ( DELIVERY_TYPE_BOOL ) ; $ this -> DeliveryMethod ( DELIVERY_METHOD_JSON ) ; ModerationController :: InformCheckedComments ( $ this ) ; $ this -> Render ( ) ; }
Looks at the user s attributes and form postback to see if any comments have been checked for administration and if so puts an inform message on the screen to take action .
46,472
public function CheckedDiscussions ( ) { $ this -> DeliveryType ( DELIVERY_TYPE_BOOL ) ; $ this -> DeliveryMethod ( DELIVERY_METHOD_JSON ) ; ModerationController :: InformCheckedDiscussions ( $ this ) ; $ this -> Render ( ) ; }
Looks at the user s attributes and form postback to see if any discussions have been checked for administration and if so puts an inform message on the screen to take action .
46,473
public function ClearCommentSelections ( $ DiscussionID = '' , $ TransientKey = '' ) { $ Session = Gdn :: Session ( ) ; if ( $ Session -> ValidateTransientKey ( $ TransientKey ) ) { $ CheckedComments = Gdn :: UserModel ( ) -> GetAttribute ( $ Session -> User -> UserID , 'CheckedComments' , array ( ) ) ; unset ( $ CheckedComments [ $ DiscussionID ] ) ; Gdn :: UserModel ( ) -> SaveAttribute ( $ Session -> UserID , 'CheckedComments' , $ CheckedComments ) ; } Redirect ( GetIncomingValue ( 'Target' , '/discussions' ) ) ; }
Remove all comments checked for administration from the user s attributes .
46,474
public function ClearDiscussionSelections ( $ TransientKey = '' ) { $ Session = Gdn :: Session ( ) ; if ( $ Session -> ValidateTransientKey ( $ TransientKey ) ) Gdn :: UserModel ( ) -> SaveAttribute ( $ Session -> UserID , 'CheckedDiscussions' , FALSE ) ; Redirect ( GetIncomingValue ( 'Target' , '/discussions' ) ) ; }
Remove all discussions checked for administration from the user s attributes .
46,475
public function getCompiled ( ) { if ( $ this -> compiled === null ) { $ regexp = "/^" ; $ methodIdx = 0 ; foreach ( $ this -> methods as $ method ) { $ regexp .= "(?:" . strtoupper ( $ method ) . ")" ; if ( ( $ methodIdx + 1 ) < count ( $ this -> methods ) ) { $ regexp .= "|" ; } $ methodIdx ++ ; } $ regexp .= "~" ; $ regexp .= str_replace ( '/' , '\/' , $ this -> match ) ; $ regexp .= "$/" ; $ this -> compiled = $ regexp ; } return $ this -> compiled ; }
Get Compiled Reg Expression key .
46,476
public function getValue ( $ key , $ default = null ) { if ( is_array ( $ this -> kwargs ) && isset ( $ this -> kwargs [ $ key ] ) ) { return $ this -> kwargs [ $ key ] ; } return $ default ; }
Get kwargs value by key return default if not found .
46,477
public function addItem ( $ id , $ content , $ title = false ) { $ this -> tooltips [ $ id ] = $ this -> newItem ( $ id , $ content , $ title ) ; }
Adds a tooltip item to the queue
46,478
protected function call ( \ LibX \ Net \ Rest \ Request $ request , \ LibX \ Net \ Rest \ Response $ response ) { $ this -> client -> execute ( $ request , $ response ) ; $ info = $ response -> getInfo ( ) ; $ json = $ response -> getData ( ) ; $ data = json_decode ( $ json ) ; return $ data ; }
Make a REST call
46,479
public function getDelete ( $ id = null ) { $ comment = Comments :: getCommentsRepository ( ) -> find ( $ id ) ; if ( $ comment == null ) { $ error = Lang :: get ( 'comments.comment.not_found' ) ; return Redirect :: route ( 'posts' ) -> with ( 'error' , $ error ) ; } Base :: Log ( 'Comment (' . $ comment -> id . ') was deleted.' ) ; $ comment -> delete ( ) ; $ success = Lang :: get ( 'comments.comment.deleted' ) ; return Redirect :: back ( ) -> with ( 'success' , $ success ) ; }
Delete the given comment .
46,480
public static function temporal_property ( $ key , $ default = null ) { $ class = get_called_class ( ) ; if ( ! array_key_exists ( $ class , static :: $ _temporal_cached ) ) { static :: temporal_properties ( ) ; } return \ Arr :: get ( static :: $ _temporal_cached [ $ class ] , $ key , $ default ) ; }
Fetches temporal property description array or specific data from it . Stolen from parent class .
46,481
public static function find_revision ( $ id , $ timestamp = null , $ relations = array ( ) ) { if ( $ timestamp == null ) { return parent :: find ( $ id ) ; } $ timestamp_start_name = static :: temporal_property ( 'start_column' ) ; $ timestamp_end_name = static :: temporal_property ( 'end_column' ) ; self :: disable_primary_key_check ( ) ; $ query = static :: query ( ) -> where ( 'id' , $ id ) -> where ( $ timestamp_start_name , '<=' , $ timestamp ) -> where ( $ timestamp_end_name , '>' , $ timestamp ) ; self :: enable_primary_key_check ( ) ; $ query -> set_temporal_properties ( $ timestamp , $ timestamp_end_name , $ timestamp_start_name ) ; foreach ( $ relations as $ relation ) { $ query -> related ( $ relation ) ; } $ query_result = $ query -> get_one ( ) ; if ( $ query_result !== null ) { $ query_result -> set_lazy_timestamp ( $ timestamp ) ; } return $ query_result ; }
Finds a specific revision for the given ID . If a timestamp is specified the revision returned will reflect the entity s state at that given time . This will also load relations when requested .
46,482
public static function find_revisions_between ( $ id , $ earliestTime = null , $ latestTime = null ) { $ timestamp_start_name = static :: temporal_property ( 'start_column' ) ; $ max_timestamp = static :: temporal_property ( 'max_timestamp' ) ; if ( $ earliestTime == null ) { $ earliestTime = 0 ; } if ( $ latestTime == null ) { $ latestTime = $ max_timestamp ; } static :: disable_primary_key_check ( ) ; $ query = static :: query ( ) -> where ( 'id' , $ id ) -> where ( $ timestamp_start_name , '>=' , $ earliestTime ) -> where ( $ timestamp_start_name , '<=' , $ latestTime ) ; static :: enable_primary_key_check ( ) ; $ revisions = $ query -> get ( ) ; return $ revisions ; }
Returns a list of revisions between the given times with the most recent first . This does not load relations .
46,483
public static function find ( $ id = null , array $ options = array ( ) ) { $ timestamp_end_name = static :: temporal_property ( 'end_column' ) ; $ max_timestamp = static :: temporal_property ( 'max_timestamp' ) ; switch ( $ id ) { case 'all' : case 'first' : case 'last' : break ; default : $ id = ( array ) $ id ; $ count = 0 ; foreach ( static :: getNonTimestampPks ( ) as $ key ) { $ options [ 'where' ] [ ] = array ( $ key , $ id [ $ count ] ) ; $ count ++ ; } break ; } $ options [ 'where' ] [ ] = array ( $ timestamp_end_name , $ max_timestamp ) ; static :: enable_id_only_primary_key ( ) ; $ result = parent :: find ( $ id , $ options ) ; static :: disable_id_only_primary_key ( ) ; return $ result ; }
Overrides the default find method to allow the latest revision to be found by default .
46,484
public static function getNonTimestampPks ( ) { $ timestamp_start_name = static :: temporal_property ( 'start_column' ) ; $ timestamp_end_name = static :: temporal_property ( 'end_column' ) ; $ pks = array ( ) ; foreach ( parent :: primary_key ( ) as $ key ) { if ( $ key != $ timestamp_start_name && $ key != $ timestamp_end_name ) { $ pks [ ] = $ key ; } } return $ pks ; }
Returns an array of the primary keys that are not related to temporal timestamp information .
46,485
public function save ( $ cascade = null , $ use_transaction = false ) { $ timestamp_start_name = static :: temporal_property ( 'start_column' ) ; $ timestamp_end_name = static :: temporal_property ( 'end_column' ) ; $ mysql_timestamp = static :: temporal_property ( 'mysql_timestamp' ) ; $ max_timestamp = static :: temporal_property ( 'max_timestamp' ) ; $ current_timestamp = $ mysql_timestamp ? \ Date :: forge ( ) -> format ( 'mysql' ) : \ Date :: forge ( ) -> get_timestamp ( ) ; if ( $ this -> is_new ( ) ) { static :: disable_primary_key_check ( ) ; $ this -> { $ timestamp_start_name } = $ current_timestamp ; $ this -> { $ timestamp_end_name } = $ max_timestamp ; static :: enable_primary_key_check ( ) ; static :: enable_id_only_primary_key ( ) ; $ result = parent :: save ( $ cascade , $ use_transaction ) ; static :: disable_id_only_primary_key ( ) ; return $ result ; } else { $ this -> observe ( 'before_save' ) ; $ this -> disable_event ( 'before_save' ) ; $ diff = $ this -> get_diff ( ) ; if ( count ( $ diff [ 0 ] ) > 0 ) { $ revision = clone $ this ; $ revision -> set ( $ this -> _original ) ; self :: disable_primary_key_check ( ) ; $ revision -> { $ timestamp_end_name } = $ current_timestamp ; self :: enable_primary_key_check ( ) ; $ revision -> _original_relations = $ this -> _data_relations ; self :: enable_id_only_primary_key ( ) ; $ revision_result = $ revision -> overwrite ( false , $ use_transaction ) ; self :: disable_id_only_primary_key ( ) ; if ( ! $ revision_result ) { return false ; } self :: disable_primary_key_check ( ) ; $ this -> { $ timestamp_start_name } = $ current_timestamp ; self :: enable_primary_key_check ( ) ; $ result = parent :: save ( $ cascade , $ use_transaction ) ; } else { $ result = parent :: save ( $ cascade , $ use_transaction ) ; } $ this -> enable_event ( 'before_save' ) ; return $ result ; } }
Overrides the save method to allow temporal models to be
46,486
public function restore ( ) { $ timestamp_end_name = static :: temporal_property ( 'end_column' ) ; $ max_timestamp = static :: temporal_property ( 'max_timestamp' ) ; $ activeRow = static :: find ( 'first' , array ( 'where' => array ( array ( 'id' , $ this -> id ) , array ( $ timestamp_end_name , $ max_timestamp ) , ) , ) ) ; if ( is_null ( $ activeRow ) ) { $ timestamp_start_name = static :: temporal_property ( 'start_column' ) ; $ mysql_timestamp = static :: temporal_property ( 'mysql_timestamp' ) ; $ max_timestamp = static :: temporal_property ( 'max_timestamp' ) ; $ current_timestamp = $ mysql_timestamp ? \ Date :: forge ( ) -> format ( 'mysql' ) : \ Date :: forge ( ) -> get_timestamp ( ) ; $ this -> _is_new = true ; static :: disable_primary_key_check ( ) ; $ this -> { $ timestamp_start_name } = $ current_timestamp ; $ this -> { $ timestamp_end_name } = $ max_timestamp ; $ result = parent :: save ( ) ; static :: enable_primary_key_check ( ) ; return $ result ; } return false ; }
Restores the entity to this state .
46,487
protected function add_primary_keys_to_where ( $ query ) { $ timestamp_start_name = static :: temporal_property ( 'start_column' ) ; $ timestamp_end_name = static :: temporal_property ( 'end_column' ) ; $ primary_key = array ( 'id' , $ timestamp_start_name , $ timestamp_end_name , ) ; foreach ( $ primary_key as $ pk ) { $ query -> where ( $ pk , '=' , $ this -> _original [ $ pk ] ) ; } }
Allows correct PKs to be added when performing updates
46,488
public static function primary_key ( ) { $ id_only = static :: get_primary_key_id_only_status ( ) ; $ pk_status = static :: get_primary_key_status ( ) ; if ( $ id_only ) { return static :: getNonTimestampPks ( ) ; } if ( $ pk_status && ! $ id_only ) { return static :: $ _primary_key ; } return array ( ) ; }
Overrides the parent primary_key method to allow primaray key enforcement to be turned off when updating a temporal model .
46,489
public static function create ( $ value , $ empty = null ) { $ value = ( ! $ value instanceof self ) && is_callable ( $ value ) ? $ value ( ) : $ value ; if ( is_callable ( $ empty ) ) { $ option = $ empty ( $ value ) ? self :: $ none : new Some ( $ value ) ; } else if ( $ value === $ empty ) { $ option = self :: $ none ; } else if ( $ value instanceof self ) { $ option = $ value ; } else { $ option = new Some ( $ value ) ; } return $ option ; }
Create new Option object .
46,490
public function getSiblings ( $ role , $ primaryOnly = false ) { $ primaryField = $ this -> getPrimaryField ( $ role ) ; $ parentObject = $ this -> owner -> parentObject ; $ childObject = $ this -> owner -> childObject ; if ( empty ( $ childObject ) ) { return [ ] ; } $ relationFields = [ ] ; if ( $ primaryOnly ) { $ relationFields [ '{{%alias%}}.[[' . $ primaryField . ']]' ] = 1 ; } return $ childObject -> siblingRelationQuery ( $ parentObject , [ 'where' => $ relationFields ] , [ 'disableAccess' => true ] ) -> all ( ) ; }
Get siblings .
46,491
public function setPrimary ( $ role ) { if ( ! $ this -> handlePrimary ( $ role ) ) { return false ; } $ primaryField = $ this -> getPrimaryField ( $ role ) ; $ primarySiblings = $ this -> getSiblings ( $ role , true ) ; foreach ( $ primarySiblings as $ sibling ) { $ sibling -> { $ primaryField } = 0 ; if ( ! $ sibling -> save ( ) ) { return false ; } } $ this -> owner -> { $ primaryField } = 1 ; return $ this -> owner -> save ( ) ; }
Set primary .
46,492
public function isPrimary ( $ role ) { if ( ! $ this -> handlePrimary ( $ role ) ) { return false ; } $ primaryField = $ this -> getPrimaryField ( $ role ) ; return ! empty ( $ this -> owner -> { $ primaryField } ) ; }
Get is primary .
46,493
public function register ( ) { $ container = $ this -> container ; $ console = new Console ( 'EncorePHP' , $ container :: VERSION ) ; $ this -> container -> bind ( 'console' , $ console ) ; if ( $ this -> container -> bound ( 'error' ) ) { $ this -> container [ 'error' ] -> setDisplayer ( new ConsoleDisplayer ( $ console ) ) ; } }
Register the console into the container .
46,494
public function boot ( ) { $ providers = $ this -> container -> providers ( false ) ; foreach ( $ providers as $ provider ) { if ( method_exists ( $ provider , 'commands' ) ) { $ this -> registerCommands ( $ provider -> commands ( ) ) ; } } }
Register service provider commands on boot .
46,495
protected function registerCommands ( array $ commands ) { foreach ( $ commands as $ command ) { if ( ! $ command instanceof SymfonyCommand ) { $ command = $ this -> container [ $ command ] ; } $ this -> container [ 'console' ] -> add ( $ command ) ; } }
Register an array of commands into the console .
46,496
public function add ( array $ params ) { foreach ( $ params as $ key => $ value ) { $ this -> set ( $ key , $ value ) ; } return $ this ; }
Add multiple parameters .
46,497
public function get ( $ key , $ default = null ) { if ( strpos ( $ key , '.' ) === false ) { $ value = isset ( $ this -> _data [ $ key ] ) ? $ this -> _data [ $ key ] : null ; } else { $ value = Hash :: get ( $ this -> _data , $ key ) ; } if ( $ value === null ) { return $ default ; } return $ value ; }
Return a parameter by key .
46,498
public function remove ( $ key ) { $ this -> _data = Hash :: remove ( $ this -> _data , $ key ) ; return $ this ; }
Remove a parameter by key .
46,499
public function set ( $ key , $ value = null ) { if ( strpos ( $ key , '.' ) === false ) { $ this -> _data [ $ key ] = $ value ; } else { $ this -> _data = Hash :: set ( $ this -> _data , $ key , $ value ) ; } return $ this ; }
Set a parameter value by key .