idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
231,400
private function changeMigrationTable ( $ migration ) { $ table = $ this -> _cap -> table ( 'migrations' ) ; $ dbm = $ table -> where ( 'migration' , '=' , $ migration ) ; if ( $ dbm -> count ( ) > 0 ) { $ item = $ dbm -> first ( ) ; $ item -> updated_at = date ( 'Y-m-d h:i:s' ) ; $ item -> migrated = 1 ; $ table -> up...
Update migrations table to reflect the migration push .
231,401
private function isMigrated ( $ migration , OutputInterface $ output = null ) { if ( $ this -> _db -> schema ( ) -> hasTable ( 'migrations' ) ) { $ table = $ this -> _cap -> table ( 'migrations' ) ; $ m = $ table -> where ( 'migration' , '=' , $ migration ) ; if ( $ m -> count ( ) > 0 ) { $ item = $ m -> first ( ) ; if...
Check whether a migration is in the database or not .
231,402
private function createMigrationsTable ( OutputInterface $ output = null ) { if ( ! is_null ( $ output ) ) { $ output -> writeln ( '<info>Creating migrations table</info>' ) ; } $ m = new CreateMigrationsTable ( ) ; $ m -> up ( ) ; }
Creates the migration table if it doesn t exist .
231,403
public function up ( ) { $ this -> create ( 'migrations' , function ( $ table ) { $ table -> increments ( 'id' ) ; $ table -> string ( 'migration' ) ; $ table -> integer ( 'migrated' ) ; $ table -> timestamps ( ) ; } ) ; }
For pushing migrations up .
231,404
public static function isIterator ( $ arr ) { if ( ! is_array ( $ arr ) ) { return false ; } foreach ( array_keys ( $ arr ) as $ key ) { if ( ! is_numeric ( $ key ) ) { return false ; } } return true ; }
Check if param is an array and can be iterated on indicating this is a collection
231,405
public static function parseResponseToPatrolObject ( Patrol $ patrol , $ data , $ class = null , $ defaults = null ) { if ( self :: isIterator ( $ data ) ) { $ parsed = [ ] ; foreach ( $ data as $ item ) { $ parsed [ ] = self :: parseResponseToPatrolObject ( $ patrol , $ item , $ class , $ defaults ) ; } return $ parse...
Parses a response to PatrolModel
231,406
public function runThreads ( $ maximumConcurrency = 10 , $ waitForCompletion = false ) { $ remainingThreads = $ this -> threads ; $ activeThreads = array ( ) ; do { foreach ( $ activeThreads as $ pid => $ thread ) { if ( $ thread -> getStatus ( ) == Thread :: THREAD_EXITED ) unset ( $ activeThreads [ $ pid ] ) ; } if (...
Run all threads defined within this thread manager enforcing the maximum concurrency flag and optionally waiting for threads to complete .
231,407
public function addRole ( string $ role , ? array $ parents = null ) : void { $ this -> roles [ ] = $ role ; if ( null !== $ parents ) { $ map = [ ] ; foreach ( $ parents as $ parent ) { $ map [ ] = $ parent ; $ map = \ array_merge ( $ map , $ this -> getRoles ( $ parent ) ) ; } unset ( $ map [ 0 ] ) ; $ this -> map [ ...
Add a role into the hierarchy
231,408
public function getPaginator ( $ params ) { $ limit = isset ( $ params [ 'limit' ] ) ? ( int ) $ params [ 'limit' ] : 10 ; $ offset = isset ( $ params [ 'offset' ] ) ? ( int ) $ params [ 'offset' ] : 0 ; $ params [ 'limit' ] = $ limit ; $ params [ 'offset' ] = $ offset ; $ fields = isset ( $ params [ 'field' ] ) ? arra...
Create paginator Object
231,409
public function getList ( $ params = array ( ) , ServiceManager $ sm ) { $ paginator = $ this -> getPaginator ( $ params ) ; $ data = array ( ) ; foreach ( $ paginator as $ post ) { $ data [ ] = $ this -> get ( $ post , $ sm ) ; } $ queryParams = array ( ) ; $ routeParams = array ( ) ; $ fields = isset ( $ params [ 'fi...
Return a normalized representation of a set of document
231,410
public function getPaginationData ( ServiceManager $ sm , $ paginator , $ data , $ routeName , $ routeParams , $ queryParams ) { $ mainService = $ sm -> get ( 'neobazaar.service.main' ) ; return array ( 'data' => $ data , 'paginationData' => Json :: decode ( $ mainService -> getView ( ) -> paginationControl ( $ paginat...
Get a pagination JSON data .
231,411
protected function initAutoHide ( ) { if ( $ this -> getIsDelayed ( ) === false ) { return null ; } $ view = $ this -> getView ( ) ; $ view -> registerJs ( $ this -> makeJs ( ) , View :: POS_READY ) ; AlertAssets :: register ( $ view ) ; }
Initialize javascript function for autoHide
231,412
public function fields ( $ fields = [ ] ) { $ this -> builder -> select ( [ ] ) ; $ this -> casts = [ ] ; if ( empty ( $ fields ) ) { foreach ( $ this -> model -> fields ( ) as $ field ) { $ this -> assignField ( $ field ) ; } return $ this ; } foreach ( $ fields as $ field ) { $ this -> assignField ( $ this -> model -...
Sets field names which will be read
231,413
protected function assignField ( FieldInterface $ field ) { if ( $ field -> mapping ( ) !== null ) { $ this -> builder -> addSelect ( sprintf ( '%s AS %s' , $ this -> connection -> quoteIdentifier ( $ field -> mapping ( ) ) , $ this -> connection -> quoteIdentifier ( $ field -> name ( ) ) ) ) ; } else { $ this -> build...
Assigns field to query
231,414
protected function buildSingularFieldCondition ( $ field , $ value , $ comparison ) { $ field = $ this -> model ( ) -> field ( $ field ) ; return $ this -> buildConditionString ( $ this -> connection ( ) -> quoteIdentifier ( $ field -> mappedName ( ) ) , $ value === null ? null : $ this -> bindValues ( $ field -> mappe...
Builds condition for singular field
231,415
protected function buildMultipleFieldsCondition ( $ fields , $ value , $ comparison , $ logical ) { $ conditions = [ ] ; foreach ( ( array ) $ fields as $ field ) { $ field = $ this -> model ( ) -> field ( $ field ) ; $ fieldName = $ field -> mappedName ( ) ; $ conditions [ ] = $ this -> buildConditionString ( $ this -...
Builds conditions for multiple fields
231,416
protected function buildConditionString ( $ field , $ bind , $ operator ) { if ( is_array ( $ bind ) ) { foreach ( $ bind as & $ val ) { $ val = $ this -> buildConditionString ( $ field , $ val , $ operator ) ; unset ( $ val ) ; } $ logical = $ operator === '!=' ? ' and ' : ' or ' ; return '(' . implode ( $ logical , $...
Builds condition string
231,417
protected function normalizeComparison ( $ operator ) { switch ( strtolower ( $ operator ) ) { case '<' : case 'lt' : return '<' ; case '<=' : case 'lte' : return '<=' ; case '>' : case 'gt' : return '>' ; case '>=' : case 'gte' : return '>=' ; case '~' : case '~=' : case '=~' : case 'regex' : case 'regexp' : return "r...
Asserts correct comparison operator
231,418
protected function normalizeLogical ( $ operator ) { switch ( strtolower ( $ operator ) ) { case '&&' : case 'and' : return 'and' ; case '||' : case 'or' : return 'or' ; default : throw new QueryException ( sprintf ( 'Query does not supports logical operator "%s" in query "%s"' , $ operator , $ this -> model ( ) -> ent...
Asserts correct logical operation
231,419
protected function bindValues ( $ name , $ type , $ values ) { if ( ! is_array ( $ values ) ) { return $ this -> builder -> createNamedParameter ( $ values , $ type ) ; } foreach ( $ values as $ key => $ value ) { $ values [ $ key ] = $ this -> bindValues ( $ name , $ type , $ value ) ; } return $ values ; }
Binds condition value to key
231,420
public function order ( $ field , $ order = 'desc' ) { $ field = $ this -> model -> field ( $ field ) ; $ order = $ this -> normalizeOrder ( $ order ) ; $ this -> builder -> addOrderBy ( $ this -> connection -> quoteIdentifier ( $ field -> mappedName ( ) ) , $ order ) ; return $ this ; }
Adds sorting to query
231,421
protected function normalizeOrder ( $ order ) { switch ( strtolower ( $ order ) ) { case 'asc' : return 'asc' ; case 'desc' : return 'desc' ; default : throw new QueryException ( sprintf ( 'Unsupported sorting method "%s" in query "%s"' , $ this -> getType ( $ order ) , $ this -> model -> entity ( ) ) ) ; } }
Asserts correct order
231,422
public function limit ( $ limit , $ offset = null ) { if ( $ offset !== null ) { $ this -> builder -> setFirstResult ( ( int ) $ offset ) ; } $ this -> builder -> setMaxResults ( ( int ) $ limit ) ; return $ this ; }
Sets limits to query
231,423
public function count ( ) { if ( empty ( $ this -> queryString ) ) { $ builder = clone $ this -> builder ; $ builder -> resetQueryPart ( 'orderBy' ) ; $ stmt = $ builder -> execute ( ) ; } else { $ stmt = $ this -> connection -> executeQuery ( $ this -> queryString , $ this -> queryParams ) ; } return ( int ) $ stmt ->...
Returns number of entities that will be read
231,424
public function query ( $ query , array $ params = [ ] ) { $ this -> queryString = $ query ; $ this -> queryParams = $ params ; return $ this ; }
Sets custom query to be executed instead of one based on entity structure
231,425
protected function executeQuery ( ) { if ( empty ( $ this -> queryString ) ) { return $ this -> builder -> execute ( ) ; } return $ this -> connection -> executeQuery ( $ this -> queryString , $ this -> queryParams ) ; }
Executes query - from builder or custom
231,426
protected function fetchAsAssoc ( Statement $ stmt ) { $ stmt -> setFetchMode ( \ PDO :: FETCH_ASSOC ) ; return $ stmt -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; }
Fetches result as associative array mostly for pivot tables
231,427
protected function fetchAsObject ( Statement $ stmt ) { $ stmt -> setFetchMode ( \ PDO :: FETCH_CLASS , $ this -> model -> entity ( ) ) ; $ result = $ stmt -> fetchAll ( ) ; $ ref = new \ ReflectionClass ( $ this -> model -> entity ( ) ) ; foreach ( $ result as $ entity ) { $ this -> restoreObject ( $ entity , $ this -...
Fetches result as entity object
231,428
protected function restoreObject ( $ entity , array $ restore , \ ReflectionClass $ ref ) { foreach ( $ restore as $ field => $ type ) { if ( is_array ( $ entity ) ) { if ( ! isset ( $ entity [ $ field ] ) ) { continue ; } $ entity [ $ field ] = $ this -> convertToPHPValue ( $ entity [ $ field ] , $ type ) ; continue ;...
Restores entity values from their stored representation
231,429
protected function convertToPHPValue ( $ value , $ type ) { return Type :: getType ( $ type ) -> convertToPHPValue ( $ value , $ this -> connection -> getDatabasePlatform ( ) ) ; }
Converts read value to its php representation
231,430
public function set_restrictions ( array $ restrictions ) { $ this -> restrictions = array ( ) ; foreach ( $ restrictions as $ k => $ v ) { switch ( $ k ) { case 'maxsize' : if ( is_int ( $ v ) ) { $ this -> restrictions [ 'maxsize' ] = $ v ; } break ; case 'mediatype' : if ( is_array ( $ v ) ) { $ this -> restrictions...
Set restrictions on file uploads .
231,431
public function validate_upload ( UploadedFile $ file ) { foreach ( $ this -> restrictions as $ k => $ v ) { switch ( $ k ) { case 'maxsize' : if ( $ v < $ file -> get_size ( ) ) { throw new Exception ( 'Received file was too large.' , Exception :: ERR_BAD_REQUEST ) ; } break ; case 'mediatype' : if ( ! in_array ( $ fi...
Validate an UploadedFile object against the list of restrictions .
231,432
public function handleupload ( $ savedir , $ savefilename = null , $ quotadata = array ( ) ) { if ( ! isset ( $ _FILES [ 'pdynfileuploader' ] ) ) { throw new Exception ( 'No file received.' , Exception :: ERR_BAD_REQUEST ) ; } if ( empty ( $ savedir ) || ! is_string ( $ savedir ) ) { throw new Exception ( 'Invalid save...
Receive an uploaded file validate it and save it .
231,433
static function fieldDefs ( $ childs = null ) { $ gname = get_called_class ( ) ; $ key = $ gname . ( $ childs ? '::' . $ childs : '' ) ; if ( key_exists ( $ key , static :: $ fieldDefCache ) ) { return static :: $ fieldDefCache [ $ key ] ; } $ defs = static :: selfFieldDefs ( $ key ) ; foreach ( class_uses ( $ gname ) ...
their traits ) . Caches results for faster lookup .
231,434
static protected function refDefs ( $ childs = null ) { $ gname = get_called_class ( ) ; $ key = $ gname . ( $ childs ? '::' . $ childs : '' ) ; if ( key_exists ( $ key , static :: $ refDefCache ) ) { return static :: $ refDefCache [ $ key ] ; } $ defs = static :: selfRefDefs ( $ key ) ; foreach ( class_uses ( $ gname ...
results for faster lookup .
231,435
static function ownsRef ( $ fname ) { $ refDefs = static :: refDefs ( ) ; $ owns = $ refDefs [ $ fname ] [ static :: OWNS ] ; if ( $ owns === null ) { throw new \ Exception ( "Invalid fname `$fname` called for ownsRef" ) ; } return $ owns ; }
Throws an exception if fname is unrecognized .
231,436
static function gnameForRef ( $ fname ) { $ refDefs = static :: refDefs ( ) ; $ gname = $ refDefs [ $ fname ] [ static :: GNAME ] ; if ( $ gname === null ) { throw new \ Exception ( "Invalid fname `$fname` called for gnameForRef" ) ; } return $ gname ; }
class . Throws an exception if fname is unrecognized .
231,437
function setKey ( $ key ) { $ this -> cnxn -> confirmTransaction ( 'setKey' ) ; $ currKey = $ this -> key ; if ( ! is_null ( $ currKey ) && is_null ( $ key ) ) { $ this -> cnxn -> unregisterStructWithKey ( $ this , $ currKey ) ; } else if ( is_null ( $ currKey ) && ! is_null ( $ key ) ) { $ this -> cnxn -> registerStru...
Subclasses can override to indicate the connection should look for a key when the struct is fetched .
231,438
private function validateTag ( $ tag ) { if ( ! preg_match ( '/[.0-9a-z]{3,3}|[.0-9A-Z]{3,3}/' , $ tag ) ) { throw new InvalidMARCspecException ( InvalidMARCspecException :: FS . InvalidMARCspecException :: FTAG , $ tag ) ; } return true ; }
validate a field tag .
231,439
public function addMethod ( $ name , $ overrideOnDefined = false ) { if ( $ this -> methods -> offsetExists ( $ name ) === true ) { if ( $ overrideOnDefined === false ) { throw Exception \ ClassFile :: methodAlreadyDefined ( $ this -> className , $ name ) ; } $ this -> methods -> offsetUnset ( $ name ) ; } if ( PHPUtil...
Create a new class method
231,440
public function addConstant ( $ name , $ value , $ overrideOnDefined = false ) { if ( $ this -> classConstants -> offsetExists ( $ name ) === true ) { if ( $ overrideOnDefined === false ) { throw Exception \ ClassFile :: constantAlreadyDefined ( $ this -> className , $ name ) ; } $ this -> classConstants -> offsetUnset...
Add a new class constant
231,441
public function addTrait ( $ trait ) { if ( $ this -> isTraitDefined ( $ trait ) === false ) { throw Exception \ Type :: isNotDefined ( $ trait ) ; } $ trait = new Element \ ClassTrait ( $ this , $ trait ) ; $ this -> classTraits -> append ( $ trait ) ; return $ trait ; }
Create a new trait
231,442
public function createSetter ( $ name , $ type = self :: PHP_TYPE_MIXED , $ default = null ) { return $ this -> internalCreateGetterAndOrSetter ( $ name , $ type , $ default , true , false ) ; }
Create property and setter method for the given name
231,443
public function index ( ) { $ this -> data [ 'page' ] -> title = 'Manage Blogs' ; $ this -> data [ 'blogs' ] = $ this -> blog_model -> getAll ( ) ; if ( empty ( $ this -> data [ 'blogs' ] ) ) { if ( ! userHasPermission ( 'admin:blog:blog:create' ) ) { $ status = 'message' ; $ message = '<strong>You don\'t have a blog!<...
Browse existing blogs
231,444
public function edit ( ) { if ( ! userHasPermission ( 'admin:blog:blog:edit' ) ) { unauthorised ( ) ; } $ this -> data [ 'blog' ] = $ this -> blog_model -> getById ( $ this -> uri -> segment ( 5 ) ) ; if ( empty ( $ this -> data [ 'blog' ] ) ) { show404 ( ) ; } $ this -> data [ 'page' ] -> title = 'Manage Blogs &rsaquo...
Edit an existing blog
231,445
public function delete ( ) { if ( ! userHasPermission ( 'admin:blog:blog:delete' ) ) { unauthorised ( ) ; } $ blog = $ this -> blog_model -> getById ( $ this -> uri -> segment ( 5 ) ) ; if ( empty ( $ blog ) ) { $ this -> session -> set_flashdata ( 'error' , 'You specified an invalid Blog ID.' ) ; redirect ( 'admin/blo...
Delete an existing blog
231,446
public static function mayHaveBody ( $ code ) { return ( $ code < self :: HTTP_CONTINUE || $ code >= self :: HTTP_OK ) && $ code != self :: HTTP_NO_CONTENT && $ code != self :: HTTP_NOT_MODIFIED ; }
Returns true for HTTP response codes that may have body .
231,447
public function isValid ( array $ values ) { foreach ( $ values as $ value ) { if ( ! $ this -> checkType ( $ value ) ) { return false ; } } return true ; }
Is the value a valid one?
231,448
protected function setValue ( $ value ) { if ( ! isset ( $ this -> value ) || null === $ this -> value ) { $ this -> value = $ value ; } return $ this ; }
Sets the value of value .
231,449
protected function setValid ( $ valid ) { if ( ! isset ( $ this -> valid ) || true === $ this -> valid ) { $ this -> valid = $ valid ; } return $ this ; }
Sets the value of valid .
231,450
public function validate ( $ value ) { return class_exists ( $ value ) || interface_exists ( $ value ) ? Ok :: unit ( ) : Error :: unit ( [ Error :: CLASS_NOT_EXISTS ] ) ; }
Tells if a given value is a fully qualified class name of an existing php class .
231,451
public function init ( $ config = NULL ) { $ this -> config = $ config ; if ( isset ( $ config [ 'debug' ] ) ) { $ this -> debug = $ config [ 'debug' ] ; } $ this -> log = $ this -> filter ( self :: ON_SET_LOG_FILTER , NULL ) ; $ this -> doAction ( self :: ON_COMPONENT_INIT_ACTION ) ; }
Initialises the component .
231,452
public function addAction ( $ action , $ callback , $ priority = 10 ) { if ( ! isset ( $ this -> actions [ $ action ] ) ) { $ this -> actions [ $ action ] = array ( ) ; } $ this -> actions [ $ action ] [ ] = array ( 'priority' => $ priority , 'callback' => $ callback , ) ; if ( 1 < count ( $ this -> actions [ $ action ...
Add a callback to execute on an action .
231,453
public function removeAction ( $ action , $ callback ) { $ i = 0 ; foreach ( $ this -> actions as $ key => $ value ) { if ( $ action === $ key ) { foreach ( $ value as $ a => $ call ) { if ( get_class ( $ callback [ 0 ] ) === get_class ( $ call [ 'callback' ] [ 0 ] ) ) { if ( $ callback [ 1 ] === $ call [ 'callback' ] ...
Removes a callback for an action .
231,454
public function doAction ( $ action , $ params = array ( ) ) { if ( isset ( $ this -> actions [ $ action ] ) ) { foreach ( $ this -> actions [ $ action ] as $ callback ) { call_user_func_array ( $ callback [ 'callback' ] , $ params ) ; if ( $ this -> debug ) { echo PHP_EOL . '->ACTION: ' . $ action . ' -> ' . $ this ->...
Executes callbacks for an action .
231,455
public function addFilter ( $ filter , $ callback , $ priority = 10 ) { if ( ! isset ( $ this -> filters [ $ filter ] ) ) { $ this -> filters [ $ filter ] = array ( ) ; } $ this -> filters [ $ filter ] [ ] = array ( 'priority' => $ priority , 'callback' => $ callback , ) ; if ( 1 < count ( $ this -> filters [ $ filter ...
Add a callback to execute to filter content .
231,456
public function removeFilter ( $ filter , $ callback ) { $ i = 0 ; foreach ( $ this -> filters as $ key => $ value ) { if ( $ filter === $ key ) { foreach ( $ value as $ f => $ call ) { if ( get_class ( $ callback [ 0 ] ) === get_class ( $ call [ 'callback' ] [ 0 ] ) ) { if ( $ callback [ 1 ] === $ call [ 'callback' ] ...
Removes a callback for a filter .
231,457
public function filter ( $ filter , $ params ) { $ argList = func_get_args ( ) ; array_shift ( $ argList ) ; if ( isset ( $ this -> filters [ $ filter ] ) ) { foreach ( $ this -> filters [ $ filter ] as $ callback ) { $ argList [ 0 ] = call_user_func_array ( $ callback [ 'callback' ] , $ argList ) ; if ( $ this -> debu...
Executes callbacks for a filter and returns the result .
231,458
public static function validIndex ( $ index , $ value ) { if ( is_array ( $ value ) ) { return ( count ( $ value ) > $ index && $ index >= 0 ) ; } elseif ( is_string ( $ value ) ) { return ( strlen ( $ value ) > $ index && $ index >= 0 ) ; } return FALSE ; }
Checks whether the value index position is valid .
231,459
private function _serializeCallback ( $ callback ) { $ retVal = $ callback ; if ( is_array ( $ callback ) && 2 === count ( $ callback ) ) { $ retVal = get_class ( $ callback [ 0 ] ) . '/' . $ callback [ 1 ] ; } return $ retVal ; }
Helper method to serialize a callback .
231,460
public static function read ( $ path ) { $ path = Normalize :: diskFullPath ( $ path ) ; if ( ! self :: exist ( $ path ) ) { return false ; } return @ file_get_contents ( $ path ) ; }
Read file content from local storage
231,461
public static function executable ( $ path ) { $ path = Normalize :: diskFullPath ( $ path ) ; if ( ! self :: exist ( $ path ) ) { return false ; } return is_executable ( $ path ) ; }
Check is file executable
231,462
public static function copy ( $ source , $ target ) { $ source = Normalize :: diskFullPath ( $ source ) ; $ target = Normalize :: diskFullPath ( $ target ) ; $ targetArray = explode ( DIRECTORY_SEPARATOR , $ target ) ; array_pop ( $ targetArray ) ; $ targetDir = implode ( DIRECTORY_SEPARATOR , $ targetArray ) ; if ( ! ...
Copy file from source to target destination
231,463
public static function inc ( $ path , $ return = false , $ once = false ) { $ path = Normalize :: diskFullPath ( $ path ) ; if ( ! self :: exist ( $ path ) ) { return false ; } if ( $ return ) { return $ once === true ? require_once ( $ path ) : require $ path ; } else { ( $ once == true ) ? require_once ( $ path ) : r...
Alternative of functions include require include_once and etc in 1 function
231,464
public static function mTime ( $ path ) { $ path = Normalize :: diskFullPath ( $ path ) ; if ( ! self :: exist ( $ path ) ) { return 0 ; } return filemtime ( $ path ) ; }
Get file make time in unix timestamp
231,465
public static function getMd5 ( $ path ) { $ path = Normalize :: diskFullPath ( $ path ) ; if ( ! self :: exist ( $ path ) ) { return false ; } return md5_file ( $ path ) ; }
Get file md5 hash
231,466
public function injectView ( $ helper ) { $ view = $ this -> getView ( ) ; if ( null === $ view ) { return ; } $ helper -> setView ( $ view ) ; }
Inject a helper instance with the registered view
231,467
public function generate ( ) { $ session = new Session ( ) ; if ( false === $ session -> has ( '_token' ) ) { $ session -> add ( '_token' , [ ] ) ; } $ name = TokenHash :: create ( 20 , true , true , true ) ; $ value = TokenHash :: create ( 40 , true , true , true ) ; $ session -> add ( '_token' , [ $ name => $ value ]...
Generates a new token and saves it into the session
231,468
public static function Parse ( $ timeDefinition ) { if ( $ timeDefinition instanceof Time ) { return $ timeDefinition ; } if ( $ timeDefinition instanceof DateTime ) { return $ timeDefinition -> getTime ( ) ; } if ( $ timeDefinition instanceof \ DateTime ) { return ( new DateTime ( $ timeDefinition ) ) -> getTime ( ) ;...
Parses a time definition to a \ Beluga \ Date \ Time instance .
231,469
public static function TryParse ( $ timeDefinition , Time & $ refTime ) : bool { if ( $ timeDefinition instanceof Time ) { $ refTime = $ timeDefinition ; return true ; } if ( $ timeDefinition instanceof DateTime ) { $ refTime = $ timeDefinition -> getTime ( ) ; return true ; } if ( $ timeDefinition instanceof \ DateTim...
Tries to parse a time definition to a \ Beluga \ Time instance .
231,470
private function getLength ( $ type = true ) { if ( $ type ) { $ start = $ this -> getCharStart ( ) ; $ end = $ this -> getCharEnd ( ) ; } else { $ start = $ this -> getIndexStart ( ) ; $ end = $ this -> getIndexEnd ( ) ; } if ( is_null ( $ start ) && is_null ( $ end ) ) { return ; } if ( ! is_null ( $ start ) && is_nu...
Calculate the length of charrange or index range .
231,471
private function validateStartEnd ( $ start , $ end ) { $ _startEnd = [ ] ; if ( preg_match ( '/[0-9]/' , $ start ) ) { $ _startEnd [ 0 ] = ( int ) $ start ; } elseif ( '#' === $ start ) { $ _startEnd [ 0 ] = '#' ; } else { throw new InvalidMARCspecException ( InvalidMARCspecException :: PR . InvalidMARCspecException :...
Validate starting and ending position .
231,472
private function validateStartLength ( $ start , $ length ) { $ _startEnd = [ ] ; if ( preg_match ( '/[0-9]/' , $ start ) ) { $ _startEnd [ 0 ] = ( int ) $ start ; } elseif ( '#' === $ start ) { $ _startEnd [ 0 ] = '#' ; } else { throw new \ UnexpectedValueException ( 'First argument must be positive int, 0 or characte...
Validate starting position and length .
231,473
public function changeState ( $ id , $ newState = 0 ) { if ( ! $ object = $ this -> find ( $ id ) ) { return false ; } $ object -> setIsActive ( $ newState ) ; $ this -> save ( $ object ) ; return true ; }
Change the state of a room type
231,474
public function readExtendedMetadata ( $ meta , array & $ config ) { $ tableName = $ meta -> getTableName ( ) ; if ( ! isset ( $ GLOBALS [ 'TL_DCA' ] [ $ tableName ] ) ) { $ this -> loadDataContainer ( $ tableName ) ; } $ dca = ( array ) $ GLOBALS [ 'TL_DCA' ] [ $ tableName ] ; $ fields = ( array ) $ dca [ 'fields' ] ;...
Read extended metadata configuration for a single mapped class
231,475
static function base ( $ url = '' , $ cacheBuster = false ) { $ cacheb = $ cacheBuster ? ( '?' . ( Config :: get ( 'app.version' , '1.0.0' ) ) ) : '' ; $ servern = $ _SERVER [ 'SERVER_NAME' ] ; $ serverp = $ _SERVER [ 'SERVER_PORT' ] ; $ server = $ serverp == '8080' || $ serverp == '80' || $ serverp == '443' ? $ server...
Get base url
231,476
static function redirect ( $ uri ) { if ( ! filter_var ( $ uri , FILTER_VALIDATE_URL ) ) { throw new \ Lollipop \ Exception \ Argument ( 'URL is invalid' , true ) ; } header ( 'location: ' . $ uri ) ; exit ( ) ; }
Redirect page to another urldecode
231,477
public function roomFormAction ( Request $ request ) { $ room = new Room ( ) ; $ this -> currentRoom = $ request -> get ( 'room' ) ; if ( $ this -> currentRoom ) { $ room = $ this -> get ( "ydle.room.manager" ) -> find ( $ request -> get ( 'room' ) ) ; } $ action = $ this -> get ( 'router' ) -> generate ( 'submitRoomFo...
Display a form to create or edit a room
231,478
protected static function splitFirstLine ( $ firstLine ) { $ parts = preg_split ( '/\\s/' , $ firstLine , null , PREG_SPLIT_NO_EMPTY ) ; if ( count ( $ parts ) > 1 ) { return $ parts ; } $ parts = explode ( ',' , $ firstLine ) ; if ( count ( $ parts ) > 1 ) { return $ parts ; } return preg_split ( '/(\\d+\\D*)/' , $ fi...
Tries to split first line into parts
231,479
public static function unload ( ViewModel $ viewmodel ) { if ( true === isset ( static :: $ views [ $ viewmodel -> getIdentifier ( ) ] ) ) { unset ( static :: $ views [ $ viewmodel -> getIdentifier ( ) ] ) ; } }
Unregister existing viewmodel
231,480
public static function output ( ViewModel $ viewmodel ) { $ viewmodel -> assign ( static :: getVariables ( ) ) ; $ template = new Template ( $ viewmodel ) ; $ template -> setDirectory ( Path :: get ( 'cache-template' ) ) ; $ template -> render ( ) ; $ file = $ template -> getFile ( ) -> entity ( ) -> getBasepath ( ) ; ...
Outputs parsed code
231,481
public static function assign ( $ key , $ value = null ) { if ( true === is_array ( $ key ) ) { static :: $ variables = array_merge ( static :: $ variables , $ key ) ; } else { static :: $ variables [ $ key ] = $ value ; } }
Assign variables to the current view
231,482
public function onComplete ( CompleteEvent $ event ) { $ code = ( string ) $ event -> getResponse ( ) -> getStatusCode ( ) ; if ( $ code [ 0 ] === '4' || $ code [ 0 ] === '5' ) { throw RequestException :: create ( $ event -> getRequest ( ) , $ event -> getResponse ( ) ) ; } }
Throw a RequestException on an HTTP protocol error
231,483
public function isPathValid ( ExecutionContextInterface $ context ) { if ( $ this -> getStorage ( ) instanceof Storage && $ this -> getStorage ( ) -> isPathRequired ( ) && ! $ this -> getPath ( ) ) { $ context -> addViolationAt ( 'path' , 'Path is required to fill for current type of storage' ) ; } }
Is valid path for current type .
231,484
public function freez ( Registry $ doctrine ) { $ em = $ doctrine -> getManager ( ) ; if ( $ this -> country ) { $ this -> country = $ em -> getReference ( get_class ( $ this -> country ) , $ this -> country -> getId ( ) ) ; } if ( $ this -> storage ) { $ this -> storage = $ em -> getReference ( get_class ( $ this -> s...
Freeze item .
231,485
public function doClearPath ( ) { if ( $ this -> not_cleared_path && $ this -> getStorage ( ) instanceof Storage && $ this -> getStorage ( ) -> getPath ( ) && strpos ( $ this -> not_cleared_path , $ this -> getStorage ( ) -> getPath ( ) ) === 0 ) { $ this -> path = substr ( $ this -> not_cleared_path , strlen ( $ this ...
Remove storage path in item path .
231,486
public function process ( $ withOutput = false ) { $ it = $ this -> _iterationCount ; if ( ! $ withOutput ) ob_start ( ) ; $ start = Snapshot :: create ( ) ; while ( $ it -- ) { call_user_func_array ( $ this -> _operation , $ this -> _args ) ; } $ end = Snapshot :: create ( ) ; if ( ! $ withOutput ) ob_get_clean ( ) ; ...
Performs the benchmark . At the start and at the end of the procedure call loop it takes a snapshot of PHP background data and returns the difference of both
231,487
protected function setDBParameters ( $ driver , $ host , $ username , $ password , $ database , $ schema = false , $ charset = 'utf8' , $ collation = 'utf8_unicode_ci' , $ options = array ( ) ) { $ this -> DBParameters = [ 'driver' => $ driver , 'host' => $ host , 'username' => $ username , 'password' => $ password , '...
sets database parameters
231,488
public function connectToDB ( ) { if ( $ this -> queryBuilder -> isConnected ( ) ) { return ; } if ( empty ( $ this -> DBParameters ) ) { throw new \ Exception ( 'missing database parameters' ) ; } $ this -> queryBuilder -> connect ( $ this -> DBParameters [ 'driver' ] , $ this -> DBParameters [ 'host' ] , $ this -> DB...
Connects to database
231,489
protected function handleError ( $ exception ) { $ error = $ this -> queryBuilder -> handleQueryException ( $ exception ) ; if ( $ error [ 0 ] && isset ( $ this -> translations [ $ this -> name ] [ $ error [ 0 ] . '_' . $ error [ 1 ] ] ) ) { $ message = $ this -> translations [ $ this -> name ] [ $ error [ 0 ] . '_' . ...
Handles a database error
231,490
protected function walk ( array $ array , $ path = '' ) { foreach ( $ array as $ k => $ v ) if ( ! is_array ( $ v ) || ! ( bool ) count ( array_filter ( array_keys ( $ v ) , 'is_string' ) ) ) $ this -> data [ $ path . $ k ] = $ v ; else $ this -> walk ( $ v , $ path . $ k . '.' ) ; }
Recursively walks over an array to flatten it s keys for faster look up .
231,491
public function get ( $ path , $ def = null ) { if ( $ this -> has ( $ path ) ) return $ this -> data [ $ path ] ; return $ def ; }
Returns the value stored at the given path .
231,492
public function save ( $ file ) { if ( ! is_writable ( dirname ( $ file ) ) ) return false ; $ f = fopen ( $ file , 'w+' ) ; if ( $ f === false ) $ check = false ; else $ check = fwrite ( $ f , $ this -> stringify ( ) ) ; fclose ( $ f ) ; return $ check ; }
Attempts to save the loaded mapping in the given file .
231,493
public function toArray ( ) { $ array = array ( ) ; foreach ( $ this -> data as $ k => $ v ) { $ nodes = explode ( '.' , $ k ) ; $ loc = & $ array ; foreach ( $ nodes as $ i => $ node ) if ( $ i === sizeof ( $ nodes ) - 1 ) $ loc [ $ node ] = $ v ; else if ( ! isset ( $ array [ $ node ] ) ) { $ loc [ $ node ] = array (...
Returns an array contaning the data held by a Yaml instance .
231,494
public static function parse ( $ input , $ typeCheck = false , $ objectSupport = false ) { return new Yaml ( parent :: parse ( $ input , $ typeCheck , $ objectSupport , $ objectForMap ) ) ; }
Parses YAML into a Yaml object .
231,495
protected function getRulesFromField ( FieldInterface $ field ) : array { $ ret = [ ] ; foreach ( $ field -> getRules ( ) as $ rule ) { $ ret [ ] = [ "description" => $ rule -> getDescription ( ) , "errorMessage" => $ rule -> getErrorMessage ( ) , ] ; } return $ ret ; }
Retreive a rules from a field
231,496
public function run ( ) { if ( $ this -> documentor ) { $ this -> documentor -> setMethodData ( $ this -> methods ) ; } $ request_xml = file_get_contents ( 'php://input' ) ; if ( ! $ request_xml ) { if ( ( $ query = $ _SERVER [ 'QUERY_STRING' ] ) && isset ( $ this -> wsdl [ $ query ] ) && $ this -> wsdl [ $ query ] ) {...
Runs the rpc server . Automatically handles an incoming request .
231,497
public function call ( $ method , $ args = null ) { if ( $ this -> methods [ $ method ] ) { $ call = $ this -> methods [ $ method ] [ 'call' ] ; return call_user_func_array ( $ call , $ args ) ; } else { if ( substr ( $ method , 0 , 7 ) == 'system.' ) { if ( $ method == 'system.multiCall' ) { throw new Ripcord_InvalidA...
Calls a method by its rpc name .
231,498
protected function readHeaders ( ) { $ ret = [ ] ; foreach ( $ this -> environment as $ key => $ value ) { if ( strpos ( $ key , "HTTP_" ) === 0 ) { $ key = substr ( $ key , 5 ) ; $ key = strtolower ( $ key ) ; $ key = str_replace ( "_" , "-" , $ key ) ; $ ret [ $ key ] = $ value ; } } return $ ret ; }
Create an array of all headers in the
231,499
protected function parseCookies ( ) : array { $ header = $ this -> getHeader ( "cookie" ) ; if ( empty ( $ header ) ) { return [ ] ; } $ options = $ this -> getDecoderOptions ( ) ; $ collection = new \ sndsgd \ http \ data \ Collection ( $ options -> getMaxVars ( ) , $ options -> getMaxNestingLevels ( ) ) ; foreach ( e...
Parse cookies from the cookie header