idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
18,600
public function removePlugin ( \ BlackForest \ PiwikBundle \ Entity \ PiwikPlugin $ plugin ) { return $ this -> plugin -> removeElement ( $ plugin ) ; }
Remove plugin .
18,601
public static function init ( $ slug , $ name , $ endpoints = null , $ type = Config :: TYPE_COLLECTION ) { $ instance = new static ( ) ; $ instance -> route = [ ] ; if ( is_array ( $ name ) ) { $ section = key ( $ name ) ; $ name = $ name [ $ section ] ; } else { $ section = $ name ; } $ instance -> route [ 'slug' ] = $ slug ; $ instance -> route [ 'name' ] = $ name ; $ instance -> route [ 'section' ] = $ section ; $ instance -> route [ 'type' ] = $ type ; $ instance -> route [ 'endpoints' ] = self :: makeEndpoints ( $ endpoints ) ; $ instance -> route [ 'groups' ] = collect ( [ ] ) ; $ instance -> route [ 'icon' ] = 'filter_list' ; return $ instance ; }
Initialise a new route . This must be called before any other method on the class
18,602
public static function load ( string $ slug ) { $ instance = new static ( ) ; $ instance -> route = [ ] ; $ instance -> route [ 'slug' ] = $ slug ; $ instance -> route [ 'groups' ] = collect ( [ ] ) ; return $ instance ; }
Creates a new Route instance for merging into an existing route collection
18,603
public static function initSingle ( $ slug , $ name , $ endpoints = [ ] ) { return self :: init ( $ slug , $ name , $ endpoints , Config :: TYPE_SINGLE ) ; }
Initialise a new single record style route .
18,604
public static function generateCrudEndpoints ( string $ permission , string $ endpoint ) { return collect ( self :: ROUTE_CRUD_PERMISSION ) -> map ( function ( $ suffix , $ method ) use ( $ permission , $ endpoint ) { if ( Gate :: allows ( "{$permission}_{$suffix}" ) ) { return [ $ method => $ endpoint ] ; } } ) -> collapse ( ) ; }
Creates a valid array of required endpoints based on the user s permissions
18,605
private static function makeEndpoints ( $ endpoints ) { if ( is_string ( $ endpoints ) ) { return self :: makeEndpointsFromString ( $ endpoints , self :: ROUTE_METHODS ) ; } return $ endpoints ; }
Creates a valid array of required endpoints
18,606
private static function makeEndpointsFromString ( $ endpoint , $ methods ) { return collect ( $ methods ) -> map ( function ( $ method ) use ( $ endpoint ) { return [ $ method => $ endpoint ] ; } ) -> collapse ( ) ; }
Creates a valid array of endpoints from a single endpoint
18,607
public function addGroup ( ... $ groups ) { collect ( $ groups ) -> map ( function ( $ group ) { $ this -> route [ 'groups' ] [ ] = $ group -> get ( ) ; } ) ; return $ this ; }
Registers a new API endpoint group
18,608
public function create ( array $ data ) { if ( ! array_key_exists ( 'name' , $ data ) ) { $ data [ 'name' ] = Str :: slug ( $ data [ 'display_name' ] ) ; } return parent :: create ( $ data ) ; }
create name before creating a new role instance .
18,609
public function directoryAction ( Request $ request ) { $ id = $ request -> query -> get ( 'id' ) ; $ parent = null ; if ( intval ( $ id ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ parent = $ em -> getReference ( 'ClasticMediaBundle:Directory' , $ id ) ; } $ directories = $ this -> getDoctrine ( ) -> getRepository ( 'ClasticMediaBundle:Directory' ) -> findBy ( array ( 'parent' => $ parent , ) ) ; $ data = array_map ( function ( Directory $ directory ) use ( $ parent ) { return array ( 'id' => $ directory -> getId ( ) , 'text' => $ directory -> getName ( ) , 'children' => true , 'state' => array ( 'disabled' => false , 'opened' => ! $ parent , 'selected' => ! $ parent , ) , ) ; } , $ directories ) ; return new JsonResponse ( $ data ) ; }
Get all directories .
18,610
public function filesAction ( Request $ request ) { $ id = $ request -> query -> get ( 'id' ) ; $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ files = $ this -> getDoctrine ( ) -> getRepository ( 'ClasticMediaBundle:File' ) -> findBy ( array ( 'directory' => $ em -> getReference ( 'ClasticMediaBundle:Directory' , $ id ) , ) ) ; $ data = array_map ( function ( File $ file ) { return array ( 'id' => $ file -> getId ( ) , 'text' => $ file -> getName ( ) , 'path' => '/uploads/documents/' . $ file -> getPath ( ) , ) ; } , $ files ) ; return new JsonResponse ( $ data ) ; }
Get all files is a specific folder .
18,611
public function getData ( ) { $ data = [ ] ; $ path = $ this -> getPath ( ) ; $ dir = new Folder ( $ path ) ; $ files = ( array ) $ dir -> find ( '.*\.php' ) ; if ( count ( $ files ) > 0 ) { foreach ( $ files as $ file ) { $ name = FS :: filename ( $ file ) ; $ segments = explode ( '_' , $ name ) ; $ version = array_shift ( $ segments ) ; $ class = Inflector :: camelize ( implode ( '_' , $ segments ) ) ; $ data [ $ version ] = [ 'class' => $ class , 'path' => $ path . DS . $ file ] ; } } return $ data ; }
Get data for migration .
18,612
public function validate_table ( $ table_name , $ input_data ) { $ errors = array ( ) ; $ table_definition = $ this -> exdb -> get_table_definition ( $ table_name ) ; if ( ! @ $ table_definition ) { $ errors [ ':common' ] = 'Table NOT Exists' ; return $ errors ; } foreach ( $ input_data as $ key => $ val ) { if ( ! @ $ table_definition -> columns -> { $ key } ) { $ errors [ ':common' ] = '"' . $ key . '" is NOT Exists in table "' . $ table_name . '".' ; } } foreach ( $ table_definition -> columns as $ column_definition ) { if ( ! array_key_exists ( $ column_definition -> name , $ input_data ) ) { continue ; } $ value = @ $ input_data [ $ column_definition -> name ] ; $ restrictions = array ( ) ; if ( $ column_definition -> not_null ) { $ restrictions [ 'required' ] = true ; } $ detect_errors = $ this -> detect_errors ( $ value , $ column_definition -> type , $ restrictions ) ; if ( count ( $ detect_errors ) ) { $ errors [ $ column_definition -> name ] = implode ( ' ' , $ detect_errors ) ; continue ; } if ( $ column_definition -> foreign_key ) { $ foreign_key = explode ( '.' , $ column_definition -> foreign_key ) ; $ foreign_row = $ this -> exdb -> select ( $ foreign_key [ 0 ] , array ( $ foreign_key [ 1 ] => $ value , ) , array ( 'limit' => 1 ) ) ; if ( ! $ foreign_row ) { $ errors [ $ column_definition -> name ] = 'Foreign key is not exists.' ; continue ; } unset ( $ foreign_key , $ foreign_row ) ; } } return $ errors ; }
Validate Table Values
18,613
public function detect_errors ( $ value , $ type , $ restrictions = array ( ) ) { $ errors = array ( ) ; $ is_required = @ $ restrictions [ 'required' ] ; if ( $ is_required && ! strlen ( $ value ) ) { array_push ( $ errors , 'Required.' ) ; return $ errors ; } if ( ! $ is_required && ! strlen ( $ value ) ) { return $ errors ; } $ type_info = $ this -> exdb -> form_elements ( ) -> get_type_info ( $ type ) ; if ( is_callable ( $ type_info [ 'validate' ] ) ) { $ errors = $ type_info [ 'validate' ] ( $ value , $ restrictions ) ; } return $ errors ; }
Detect Input Errors
18,614
private function _MapParts ( $ Parts , $ ControllerKey ) { $ Length = count ( $ Parts ) ; if ( $ Length > $ ControllerKey ) $ this -> ControllerName = ucfirst ( strtolower ( $ Parts [ $ ControllerKey ] ) ) ; if ( $ Length > $ ControllerKey + 1 ) list ( $ this -> ControllerMethod , $ this -> _DeliveryMethod ) = $ this -> _SplitDeliveryMethod ( $ Parts [ $ ControllerKey + 1 ] ) ; if ( $ Length > $ ControllerKey + 2 ) { for ( $ i = $ ControllerKey + 2 ; $ i < $ Length ; ++ $ i ) { if ( $ Parts [ $ i ] != '' ) $ this -> _ControllerMethodArgs [ ] = $ Parts [ $ i ] ; } } }
An internal method used to map parts of the request to various properties of this object that represent the controller controller method and controller method arguments .
18,615
protected function _SplitDeliveryMethod ( $ Name , $ AllowAll = FALSE ) { $ Parts = explode ( '.' , $ Name ) ; if ( count ( $ Parts ) >= 2 ) { $ DeliveryPart = array_pop ( $ Parts ) ; $ MethodPart = implode ( '.' , $ Parts ) ; if ( $ AllowAll || in_array ( strtoupper ( $ DeliveryPart ) , array ( DELIVERY_METHOD_JSON , DELIVERY_METHOD_XHTML , DELIVERY_METHOD_XML , DELIVERY_METHOD_TEXT , DELIVERY_METHOD_RSS ) ) ) { return array ( $ MethodPart , strtoupper ( $ DeliveryPart ) ) ; } else { return array ( $ Name , $ this -> _DeliveryMethod ) ; } } else { return array ( $ Name , $ this -> _DeliveryMethod ) ; } }
Parses methods that may be using dot - syntax to express a delivery type
18,616
protected function addMessage ( $ message , $ namespace = FlashMessenger :: NAMESPACE_DEFAULT ) { if ( null === $ this -> messenger ) { $ this -> messenger = $ this -> getServiceLocator ( ) -> get ( 'ControllerPluginManager' ) -> get ( 'flashMessenger' ) ; } $ this -> messenger -> setNamespace ( $ namespace ) ; $ message = ( array ) $ message ; foreach ( $ message as $ value ) { $ this -> messenger -> addMessage ( $ value ) ; } }
Add a message to the flashMessenger
18,617
protected function getFormElementManager ( ) { if ( null === $ this -> formElementManager ) { $ this -> formElementManager = $ this -> getServiceLocator ( ) -> get ( 'FormElementManager' ) ; } return $ this -> formElementManager ; }
Retrieve form element manager
18,618
protected function getForm ( $ name ) { if ( ! isset ( $ this -> form [ $ name ] ) ) { $ this -> form [ $ name ] = $ this -> getServiceLocator ( ) -> get ( $ this -> getModuleNamespace ( ) . '\Form\\' . $ name ) ; } return $ this -> form [ $ name ] ; }
Retrieve a form
18,619
protected function getMapper ( ) { if ( null === $ this -> mapper ) { $ this -> mapper = $ this -> getServiceLocator ( ) -> get ( $ this -> getModuleNamespace ( ) . '\Mapper\\' . $ this -> getEntityName ( ) ) ; } return $ this -> mapper ; }
Retrieve the mapper
18,620
protected function getCallbackFromReference ( $ reference ) : callable { $ this -> reference = $ reference ; if ( is_callable ( $ reference ) ) { if ( ! is_string ( $ reference ) ) { $ callback = $ reference ; } else { $ parts = explode ( "::" , $ reference ) ; $ callback = [ new $ parts [ 0 ] ( ) , $ parts [ 1 ] ] ; } } else { $ callback = function ( ) use ( $ reference ) { new RegularResponse ( $ reference ) ; } ; } return $ callback ; }
Call this when action calling to make Controller in a time
18,621
public function initialize ( $ value , $ filters = [ ] ) { $ this -> value = $ value ; if ( empty ( $ filters ) ) return ; if ( is_string ( $ filters ) ) { $ this -> filters = explode ( ',' , $ filters ) ; } else if ( ! is_array ( $ filters ) ) { $ this -> filters = [ $ this -> filters ] ; } else { $ this -> filters = $ filters ; } }
Constructor must have the value and filters
18,622
public function getData ( ) { $ this -> fetchData ( ) ; $ this -> preProcessData ( ) ; $ this -> applyFilters ( ) ; $ this -> postProcessData ( ) ; return $ this -> output ; }
Get data but supply filters
18,623
protected function postProcessData ( ) { $ comment = "\n/* " . ( ! empty ( $ this -> filters ) ? implode ( '|' , $ this -> filters ) . '::' : '' ) . $ this -> value . " */\n" ; $ this -> output = $ comment . $ this -> output ; }
Post process data
18,624
protected function getFilterOutput ( $ filter , $ input ) { if ( $ filter [ 0 ] == '\\' ) { $ filterClass = $ filter ; } else { $ filterClass = '\Slab\Concatenator\Filters\\' . $ filter ; } if ( ! class_exists ( $ filterClass ) ) { throw new \ Exception ( "Invalid filter class specified: " . $ filterClass ) ; } $ filterObject = new $ filterClass ( ) ; $ filterObject -> filter ( $ input ) ; return $ filterObject -> getOutput ( ) ; }
Get filter output
18,625
public function notify ( ) { if ( $ this -> requirements_met ( ) ) { return ; } echo '<div class="notice notice-error">' ; foreach ( $ this -> requirements as $ requirement ) { if ( $ requirement -> is_met ( ) ) { continue ; } printf ( '<p>%s deactivated: %s</p>' , esc_html ( $ this -> name ) , esc_html ( $ requirement -> get_message ( ) ) ) ; } echo '</div>' ; }
Print an admin notice for each failed requirement .
18,626
public function php_at_least ( $ version ) { return $ this -> add_check ( function ( ) use ( $ version ) { return version_compare ( phpversion ( ) , $ version , '>=' ) ; } , sprintf ( 'PHP %s or newer is required' , $ version ) ) ; }
Verify that a minimum PHP version is met .
18,627
public function plugin_active ( $ plugin_file , $ plugin_name ) { return $ this -> add_check ( function ( ) use ( $ plugin_file ) { return in_array ( $ plugin_file , ( array ) get_option ( 'active_plugins' ) , true ) ; } , sprintf ( '%s must be installed and active' , $ plugin_name ) ) ; }
Check whether a plugin is active .
18,628
public function requirements_met ( ) { $ met = true ; foreach ( $ this -> requirements as $ requirement ) { $ met = $ met && $ requirement -> is_met ( ) ; } return $ met ; }
Detemine if all requirements are met .
18,629
public function wp_at_least ( $ version ) { return $ this -> add_check ( function ( ) use ( $ version ) { return version_compare ( get_bloginfo ( 'version' ) , $ version , '>=' ) ; } , sprintf ( 'WordPress %s or newer is required' , $ version ) ) ; }
Verify that a minimum WP version is met .
18,630
protected function routesRegister ( string $ file , string $ namespace ) { $ this -> app -> router -> group ( [ 'namespace' => $ namespace , ] , function ( $ router ) use ( $ file ) { require $ file ; } ) ; }
Register routes in system .
18,631
protected function getFQCN ( $ entity_name ) { $ parts = explode ( ':' , $ entity_name ) ; $ entity = end ( $ parts ) ; if ( 1 === preg_match ( '/^([A-Z][a-zA-Z]+)([A-Z][a-zA-Z]+)(Bundle)$/' , $ parts [ 0 ] , $ matches ) ) { return $ matches [ 1 ] . '\\' . $ matches [ 2 ] . $ matches [ 3 ] . '\\Entity\\' . $ entity ; } return $ entity_name ; }
Return FQCN entity name .
18,632
public function createInstance ( ) { if ( is_null ( $ this -> entityName ) ) { $ class = new \ ReflectionClass ( $ this -> originalEntityName ) ; } else { $ class = new \ ReflectionClass ( $ this -> entityName ) ; } return $ class -> newInstanceArgs ( ) ; }
Create new instance of the entity .
18,633
function get_by_id ( $ id , $ ammend_query = '' ) { if ( isset ( self :: $ _cache [ $ this -> _table ] [ $ id ] ) ) { return self :: $ _cache [ $ this -> _table ] [ $ id ] ; } $ q = \ Fw \ Db :: prepare ( "select * from " . $ this -> _table . " where id=? " . $ ammend_query ) ; $ q -> execute ( array ( $ id ) ) ; $ res = $ q -> fetchObject ( $ this -> _entity ) ; self :: $ _cache [ $ this -> _table ] [ $ id ] = $ res ; return $ res ; }
Get by ID Helper . Benefits from caching
18,634
function get_by ( $ field , $ value ) { $ q = \ Fw \ Db :: prepare ( "select * from " . $ this -> _table . " where " . $ field . "=?" ) ; $ q -> execute ( array ( $ value ) ) ; return $ q -> fetchAll ( \ PDO :: FETCH_CLASS , $ this -> _entity ) ; }
Get by Arbitary Field
18,635
public function handleRequest ( Request $ request , Language $ language ) { $ uri = $ this -> getRequestedPath ( $ request , $ language ) ; $ route = $ this -> repository -> getByPath ( $ uri , $ language -> code ) ; if ( empty ( $ route ) || $ route -> getRoutable ( ) === null ) { throw new NotFoundHttpException ( ) ; } if ( ! $ this -> routeCanBeShown ( $ route ) ) { throw new NotFoundHttpException ( ) ; } event ( new RouteMatched ( $ route , $ request ) ) ; return $ route -> getRoutable ( ) -> handle ( $ language ) ; }
Handles dynamic content rendering
18,636
public static function getAllEntityDescriptors ( ) { $ entities = array ( ) ; foreach ( static :: getAllEntities ( ) as $ entity ) { $ entities [ $ entity ] = EntityDescriptor :: load ( $ entity ) ; } return $ entities ; }
Get all available entity descriptor
18,637
public static function getAllEntities ( ) { $ entities = cleanscandir ( pathOf ( CONFDIR . ENTITY_DESCRIPTOR_CONFIG_PATH ) ) ; foreach ( $ entities as $ i => & $ filename ) { $ pi = pathinfo ( $ filename ) ; if ( $ pi [ 'extension' ] != 'yaml' ) { unset ( $ entities [ $ i ] ) ; continue ; } $ filename = $ pi [ 'filename' ] ; } return $ entities ; }
Get all available entities
18,638
public static function load ( $ name , $ class = null ) { $ descriptorPath = ENTITY_DESCRIPTOR_CONFIG_PATH . $ name ; $ cache = new FSCache ( self :: DESCRIPTORCLASS , $ name , filemtime ( YAML :: getFilePath ( $ descriptorPath ) ) ) ; $ descriptor = null ; try { if ( ! defined ( 'ENTITY_ALWAYS_RELOAD' ) && $ cache -> get ( $ descriptor ) && isset ( $ descriptor -> version ) && $ descriptor -> version == self :: VERSION ) { return $ descriptor ; } } catch ( Exception $ e ) { $ cache -> reset ( ) ; } $ conf = YAML :: build ( $ descriptorPath , true ) ; if ( empty ( $ conf -> fields ) ) { throw new \ Exception ( 'Descriptor file for "' . $ name . '" is corrupted, empty or not found, there is no field.' ) ; } $ fields = array ( ) ; if ( ! empty ( $ conf -> parent ) ) { if ( ! is_array ( $ conf -> parent ) ) { $ conf -> parent = array ( $ conf -> parent ) ; } foreach ( $ conf -> parent as $ p ) { $ p = static :: load ( $ p ) ; if ( ! empty ( $ p ) ) { $ fields = array_merge ( $ fields , $ p -> getFields ( ) ) ; } } } $ IDField = $ class ? $ class :: getIDField ( ) : self :: IDFIELD ; $ fields [ $ IDField ] = FieldDescriptor :: buildIDField ( $ IDField ) ; foreach ( $ conf -> fields as $ fieldName => $ fieldInfos ) { $ fields [ $ fieldName ] = FieldDescriptor :: parseType ( $ fieldName , $ fieldInfos ) ; } $ indexes = array ( ) ; if ( ! empty ( $ conf -> indexes ) ) { foreach ( $ conf -> indexes as $ index ) { $ iType = static :: parseType ( null , $ index ) ; $ indexes [ ] = ( object ) array ( 'name' => $ iType -> default , 'type' => strtoupper ( $ iType -> type ) , 'fields' => $ iType -> args ) ; } } $ descriptor = new EntityDescriptor ( $ name , $ fields , $ indexes , $ class ) ; if ( ! empty ( $ conf -> flags ) ) { if ( in_array ( self :: FLAG_ABSTRACT , $ conf -> flags ) ) { $ descriptor -> setAbstract ( true ) ; } } $ cache -> set ( $ descriptor ) ; return $ descriptor ; }
Load an entity descriptor from configuraiton file
18,639
public function validateFieldValue ( $ fieldName , & $ value , $ input = array ( ) , $ ref = null ) { if ( ! isset ( $ this -> fields [ $ fieldName ] ) ) { throw new InvalidFieldException ( 'unknownField' , $ fieldName , $ value , null , $ this -> name ) ; } $ field = $ this -> getField ( $ fieldName ) ; if ( ! $ field -> writable ) { throw new InvalidFieldException ( 'readOnlyField' , $ fieldName , $ value , null , $ this -> name ) ; } $ TYPE = $ field -> getType ( ) ; $ TYPE -> preFormat ( $ field , $ value , $ input , $ ref ) ; if ( $ value === NULL || ( $ value === '' && $ TYPE -> emptyIsNull ( $ field ) ) ) { $ value = null ; if ( isset ( $ field -> default ) ) { $ value = $ field -> getDefault ( ) ; } else if ( ! $ field -> nullable ) { throw new InvalidFieldException ( 'requiredField' , $ fieldName , $ value , null , $ this -> name ) ; } return ; } try { $ TYPE -> validate ( $ field , $ value , $ input , $ ref ) ; if ( ! empty ( $ field -> validator ) ) { call_user_func_array ( $ field -> validator , array ( $ field , & $ value , $ input , & $ ref ) ) ; } } catch ( FE $ e ) { throw new InvalidFieldException ( $ e -> getMessage ( ) , $ fieldName , $ value , $ field -> type , $ this -> name , $ field -> args ) ; } $ TYPE -> format ( $ field , $ value ) ; }
Validate a value for a specified field an exception is thrown if the value is invalid
18,640
public static function getType ( $ name , & $ type = null ) { if ( ! isset ( static :: $ types [ $ name ] ) ) { throw new Exception ( 'unknownType_' . $ name ) ; } $ type = & static :: $ types [ $ name ] ; return $ type ; }
Get a type by name
18,641
public static function parseType ( $ fieldName , $ desc ) { $ result = array ( 'type' => null , 'args' => array ( ) , 'default' => null , 'flags' => array ( ) ) ; $ matches = null ; if ( ! preg_match ( '#([^\(\[=]+)(?:\(([^\)]*)\))?(?:\[([^\]]*)\])?(?:=([^\[]*))?#' , $ desc , $ matches ) ) { throw new Exception ( 'failToParseType' ) ; } $ result [ 'type' ] = trim ( $ matches [ 1 ] ) ; $ result [ 'args' ] = ! empty ( $ matches [ 2 ] ) ? preg_split ( '#\s*,\s*#' , $ matches [ 2 ] ) : array ( ) ; $ result [ 'flags' ] = ! empty ( $ matches [ 3 ] ) ? preg_split ( '#\s#' , $ matches [ 3 ] , - 1 , PREG_SPLIT_NO_EMPTY ) : array ( ) ; if ( isset ( $ matches [ 4 ] ) ) { $ result [ 'default' ] = $ matches [ 4 ] ; if ( $ result [ 'default' ] === 'true' ) { $ result [ 'default' ] = true ; } else if ( $ result [ 'default' ] === 'false' ) { $ result [ 'default' ] = false ; } else { $ len = strlen ( $ result [ 'default' ] ) ; if ( $ len && $ result [ 'default' ] [ $ len - 1 ] == ')' ) { $ result [ 'default' ] = static :: parseType ( $ fieldName , $ result [ 'default' ] ) ; } } } return ( object ) $ result ; }
parse type from configuration string
18,642
public function setMinViewability ( $ value = null ) { switch ( $ value ) { case 'full_view' : $ this -> _params [ 'min-viewability' ] = 'full' ; break ; case 'partial_view' : $ this -> _params [ 'min-viewability' ] = 'partial' ; break ; case null : unset ( $ this -> _params [ 'min-viewability' ] ) ; break ; } return $ this ; }
Sets the minimum level of viewability of volumes to return in the search results
18,643
public function getQueryUrl ( ) { if ( isset ( $ this -> _url ) ) { $ url = $ this -> _url ; } else { $ url = Zend_Gdata_Books :: VOLUME_FEED_URI ; } if ( $ this -> getCategory ( ) !== null ) { $ url .= '/-/' . $ this -> getCategory ( ) ; } $ url = $ url . $ this -> getQueryString ( ) ; return $ url ; }
Returns the generated full query URL
18,644
public function gist ( $ id , $ file = null ) { if ( $ this -> cache ( ) -> exists ( $ id ) ) { $ gist = $ this -> cache ( ) -> get ( $ id ) ; } else { $ gist = $ this -> transport ( ) -> fetchGist ( $ id ) ; $ this -> cache ( ) -> set ( $ id , $ gist ) ; } $ files = array ( ) ; foreach ( $ gist [ 'files' ] as $ name => $ fileInfo ) { if ( $ file === null ) { $ files [ $ name ] = $ fileInfo ; } else { if ( $ file == $ name ) { $ files [ $ name ] = $ fileInfo ; break ; } } } if ( ! count ( $ files ) ) { return '' ; } $ urlExtra = $ file ? '?file=' . $ file : '' ; $ output = '' ; $ output .= '<script src="https://gist.github.com/' . $ id . '.js' . $ urlExtra . '"></script>' ; $ output .= '<noscript>' ; foreach ( $ files as $ name => $ fileInfo ) { $ language = strtolower ( $ fileInfo [ 'language' ] ) ; $ output .= '<pre><code class="language-' . $ language . ' ' . $ language . '">' ; $ output .= htmlentities ( $ fileInfo [ 'content' ] ) ; $ output .= '</code></pre>' ; } $ output .= '</noscript>' ; return $ output ; }
Get the HTML content for a GitHub Gist
18,645
public function run ( ) { $ this -> container -> get ( 'app' ) -> run ( $ this -> container -> get ( 'app.input' ) , $ this -> container -> get ( 'app.output' ) ) ; }
Execute CLI application .
18,646
private function GenerateOutput ( $ source ) { array_push ( $ this -> Attributes , HtmlAttribute :: Instanciate ( HtmlAttributeConstants :: Src , $ source ) ) ; $ this -> HtmlOutput = '<script type="application/javascript" {0}></script>' ; HtmlControlBuildHelper :: Init ( ) -> GenerateAttributes ( $ this ) ; }
Generates a script html tag to include a script in the DOM
18,647
public function start ( ) { foreach ( $ this -> processes as $ process ) { $ process -> start ( ) ; $ this -> updateStatus ( ) ; while ( $ this -> runningProcesses ( ) >= $ this -> concurrent ) { usleep ( self :: SLEEP_INTERVAL ) ; $ this -> updateStatus ( ) ; } } $ this -> wait ( ) ; }
Start the processes in the pool
18,648
protected function runningProcesses ( ) { $ count = 0 ; foreach ( $ this -> processes as $ process ) { if ( $ process -> isRunning ( ) ) { $ count ++ ; } } return $ count ; }
Counts the number of running processes in the pool
18,649
protected function updateStatus ( $ alwaysNotify = false ) { $ this -> previousStatus = $ this -> status ; $ this -> status = [ ] ; foreach ( $ this -> processes as $ process ) { $ this -> status [ ] = $ process -> getStatus ( ) ; } if ( $ this -> previousStatus != $ this -> status || $ alwaysNotify ) { if ( is_callable ( $ this -> updateCallback ) ) { call_user_func ( $ this -> updateCallback , $ this -> status ) ; } } }
Updates the status of all processes
18,650
private static function validateName ( string $ name ) : string { if ( empty ( $ name ) || preg_match ( "/[=,; \t\r\n\013\014]/" , $ name ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid name \'%s\'.' , $ name ) ) ; } return $ name ; }
Validates the name and returns it
18,651
private static function validateExpires ( $ expires ) : int { if ( is_numeric ( $ expires ) ) { return ( int ) $ expires ; } if ( $ expires instanceof \ DateInterval ) { $ now = new \ DateTime ( 'now' ) ; return ( int ) $ now -> add ( $ expires ) -> format ( 'U' ) ; } if ( $ expires instanceof \ DateTimeInterface ) { return ( int ) $ expires -> format ( 'U' ) ; } $ expires = strtotime ( $ expires ) ; if ( false === $ expires || - 1 === $ expires ) { throw new \ InvalidArgumentException ( 'The expiration time is not valid.' ) ; } return $ expires ; }
Convert expiration time to a Unix timestamp
18,652
public function toHeaderLine ( ) : string { $ cookie = sprintf ( '%s=%s' , $ this -> name , urlencode ( $ this -> value ) ) ; if ( $ this -> expires !== 0 ) { $ cookie .= sprintf ( '; expires=%s' , gmdate ( 'D, d-M-Y H:i:s T' , $ this -> expires ) ) ; } if ( ! empty ( $ this -> path ) ) { $ cookie .= sprintf ( '; path=%s' , $ this -> path ) ; } if ( ! empty ( $ this -> domain ) ) { $ cookie .= sprintf ( '; domain=%s' , $ this -> domain ) ; } if ( ! empty ( $ this -> secure ) ) { $ cookie .= '; secure' ; } if ( ! empty ( $ this -> httpOnly ) ) { $ cookie .= '; httponly' ; } return $ cookie ; }
Returns headerline from this cookie
18,653
public function extractRecordedEvents ( ) { $ eventCollection = $ this -> eventCollection ( ) ; $ eventStream = $ eventCollection -> stream ( ) ; $ eventCollection -> commit ( ) ; $ this -> committedVersion = $ eventCollection -> committedSequence ( ) ; return $ eventStream ; }
Removes and returns recorded events
18,654
public function committedVersion ( ) : ? int { if ( $ this -> committedVersion === null ) { $ this -> committedVersion = $ this -> eventCollection ( ) -> committedSequence ( ) ; } return $ this -> committedVersion ; }
Retrieves the committed version
18,655
protected function initializeCommittedVersion ( int $ committedVersion ) : void { if ( ! $ this -> eventCollection ( ) -> isEmpty ( ) ) { $ message = 'Cannot initialize version after recording events' ; throw new OperationException ( $ message ) ; } $ this -> eventCollection ( ) -> initializeSequence ( $ committedVersion ) ; }
Initializes the committed version
18,656
protected function eventCollection ( ) : EventCollection { if ( $ this -> eventCollection === null ) { $ this -> eventCollection = new EventCollection ( $ this -> id ( ) , Type :: create ( $ this ) ) ; } return $ this -> eventCollection ; }
Retrieves the event collection
18,657
public static function endsWith ( $ string , $ suffix ) { return ( mb_strrpos ( $ string , $ suffix ) === mb_strlen ( $ string ) - mb_strlen ( $ suffix ) ) ; }
Does string end with suffix?
18,658
public static function lineNumbers ( $ code , $ eol = "\n" , $ begin = 1 ) { $ cut = FALSE ; if ( ! static :: endsWith ( $ code , $ eol ) ) { $ code .= $ eol ; $ cut = - mb_strlen ( $ eol ) ; } $ lines = mb_substr_count ( $ code , $ eol ) ; $ padWhite = mb_strlen ( ( string ) $ lines ) ; $ cnt = $ begin ; $ linedCode = Preg :: replace_callback ( $ code , '/(.*?)' . $ eol . '/' , function ( $ match ) use ( & $ cnt , $ padWhite ) { return sprintf ( '%s %s' , StringUtil :: padRight ( ( string ) $ cnt ++ , $ padWhite , ' ' ) , $ match [ 0 ] ) ; } ) ; if ( $ cut !== FALSE ) { return mb_substr ( $ linedCode , 0 , $ cut ) ; } else { return $ linedCode ; } }
Number the lines in the string
18,659
public static function random ( $ length ) { if ( $ length <= 0 ) return '' ; $ str = '' ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ rand = rand ( 0 , 35 ) ; if ( $ rand >= 10 ) $ str .= chr ( ord ( 'a' ) + $ rand - 10 ) ; else $ str .= chr ( ord ( '0' ) + $ rand ) ; } return $ str ; }
Generates a Random string from specific length
18,660
public function getFieldsInQuery ( ) { $ query = isset ( $ this -> query [ 'query' ] ) ? $ this -> query [ 'query' ] : array ( ) ; $ sort = isset ( $ this -> query [ 'sort' ] ) ? $ this -> query [ 'sort' ] : array ( ) ; $ extractor = new FieldExtractor ( $ query , $ sort ) ; return $ extractor -> getFields ( ) ; }
Gets the fields involved in this query .
18,661
public function isIndexed ( ) { $ fields = $ this -> getFieldsInQuery ( ) ; foreach ( $ fields as $ field ) { if ( ! $ this -> collection -> isFieldIndexed ( $ field ) ) { return false ; } } return true ; }
Check if this query is indexed .
18,662
public function getUnindexedFields ( ) { $ unindexedFields = array ( ) ; $ fields = $ this -> getFieldsInQuery ( ) ; foreach ( $ fields as $ field ) { if ( ! $ this -> collection -> isFieldIndexed ( $ field ) ) { $ unindexedFields [ ] = $ field ; } } return $ unindexedFields ; }
Gets an array of the unindexed fields in this query .
18,663
public function hasAction ( $ controller , $ action = null ) { if ( $ action === null ) { list ( $ controller , $ action ) = explode ( '.' , $ controller ) ; } return in_array ( "{$controller}.{$action}" , $ this -> action_names ) ; }
has action ?
18,664
public function getCurrentAction ( ) { if ( ! isset ( $ this -> actions [ $ this -> position ] ) ) return null ; $ define = $ this -> actions [ $ this -> position ] ; if ( $ define [ 'controller' ] ) return $ define ; $ controller = $ this -> getController ( $ define [ 'controller_name' ] ) ; $ define [ 'controller' ] = $ controller ; $ this -> actions [ $ this -> position ] = $ define ; return $ define ; }
Get current action instance .
18,665
public function getCurrentActionName ( ) { return isset ( $ this -> action_names [ $ this -> position ] ) ? $ this -> action_names [ $ this -> position ] : null ; }
get current action name
18,666
public function getController ( $ name ) { $ names = explode ( '_' , $ name ) ; array_unshift ( $ names , 'Controller' ) ; foreach ( $ this -> application -> config ( 'controller.namespaces' ) as $ ns ) { $ class = $ ns . '\\' . join ( '\\' , array_map ( 'ucfirst' , $ names ) ) . 'Controller' ; if ( class_exists ( $ class ) ) { $ controller = new $ class ( ) ; $ controller -> setContainer ( $ this -> getContainer ( ) ) ; $ this -> getContainer ( ) -> injectDependency ( $ controller ) ; $ controller -> setName ( $ name ) ; return $ controller ; } } throw new NotFoundException ( ) ; }
cteate and return controller .
18,667
public function existsController ( $ name , $ action = null ) { $ names = explode ( '_' , $ name ) ; array_unshift ( $ names , 'Controller' ) ; $ base = join ( DS , array_map ( 'ucfirst' , $ names ) ) . 'Controller.php' ; $ file = $ this -> loader -> findFirst ( $ base ) ; if ( $ file ) { $ class = $ file -> getClassName ( ) ; if ( ! $ action && class_exists ( $ class ) ) return true ; $ action = $ this -> actionNameStrategy ( $ action ) ; if ( method_exists ( $ class , $ action ) ) return true ; } return false ; }
has controller ?
18,668
public function getErrorListByName ( $ controller , $ action = null ) { $ position = $ this -> getPositionByName ( $ controller , $ action ) ; if ( is_integer ( $ position ) ) { if ( ! isset ( $ this -> errors [ $ position ] ) ) $ this -> errors [ $ position ] = new ErrorList ( ) ; return $ this -> errors [ $ position ] ; } }
get error list by name
18,669
public function getErrorLists ( ) { $ names = array_values ( $ this -> action_names ) ; $ errors = [ ] ; foreach ( $ names as $ name ) { $ errors [ $ name ] = $ this -> getErrorListByName ( $ name ) ; } return $ errors ; }
get error lists
18,670
public function getPositionByName ( $ controller , $ action = null ) { if ( $ action === null ) { list ( $ controller , $ action ) = explode ( '.' , $ controller ) ; } return array_search ( "{$controller}.{$action}" , $ this -> action_names ) ; }
get position by name
18,671
public function controllerClassNameStrategy ( $ name ) { $ names = explode ( '_' , $ name ) ; $ names = array_map ( 'ucfirst' , $ names ) ; return join ( '\\' , $ names ) . 'Controller' ; }
controller class name strategy
18,672
public function actionNameStrategy ( $ name ) { $ names = explode ( '_' , $ name ) ; $ names = array_map ( 'ucfirst' , $ names ) ; return lcfirst ( join ( '' , $ names ) ) . 'Action' ; }
action name strategy
18,673
protected function checkStarted ( ) : bool { if ( ! $ this -> started ) { $ this -> started = self :: sessionStart ( ) ; } if ( isset ( $ _SESSION [ $ this -> namespace ] ) && ! is_array ( $ _SESSION [ $ this -> namespace ] ) ) { $ _SESSION [ $ this -> namespace ] = [ ] ; } return ( bool ) $ this -> started ; }
Check if session started if not start it
18,674
public function addProperties ( $ properties ) { foreach ( $ properties as $ key => $ value ) { $ this -> setProperty ( $ key , $ value ) ; } return $ this ; }
Add properties .
18,675
public function getNamespaceName ( ) { $ caller = get_called_class ( ) ; $ parts = explode ( '\\' , $ caller ) ; array_pop ( $ parts ) ; return join ( '\\' , $ parts ) ; }
Returns the name of the class namespace
18,676
protected static function toss ( $ exception , $ message , $ code = 0 ) { $ args = array_values ( get_defined_vars ( ) ) ; foreach ( func_get_args ( ) as $ i => $ value ) { $ args [ $ i ] = $ value ; } list ( $ exception , $ message , $ code ) = array_splice ( $ args , 0 , 3 ) ; $ exception = self :: getNamespaceName ( ) . "\\Exceptions\\{$exception}" ; if ( strpos ( $ exception , 'Headzoo\Core\\' ) === 0 && substr ( $ exception , - 9 ) != "Exception" ) { $ exception .= "Exception" ; } if ( ! is_int ( $ code ) ) { array_unshift ( $ args , $ code ) ; $ code = 0 ; } $ placeholders = array_merge ( $ args , [ "me" => get_called_class ( ) , "exception" => $ exception , "code" => $ code , "date" => date ( "Y-m-d H:i:s" ) ] ) ; $ message = self :: interpolate ( $ message , $ placeholders ) ; throw new $ exception ( $ message , $ code ) ; }
Throws an exception from the calling class namespace
18,677
public static function select ( $ table , array $ data = array ( ) , array $ where = array ( ) , $ order = array ( ) , $ limit = null ) { $ query = 'SELECT ' ; $ values = array ( ) ; if ( count ( $ data ) > 0 ) { foreach ( $ data as $ v ) { $ query .= $ v . ', ' ; } $ query = substr ( $ query , 0 , - 2 ) . ' ' ; } else { $ query .= '* ' ; } $ query .= 'FROM ' . self :: escapeTableName ( $ table ) . ' ' ; $ query .= self :: processWhere ( $ where , $ values ) ; if ( count ( $ order ) > 0 ) { $ query .= " ORDER BY " ; foreach ( $ order as $ v ) { $ query .= $ v . ", " ; } $ query = substr ( $ query , 0 , - 2 ) ; } if ( $ limit ) { $ query .= " LIMIT " . $ limit ; } $ query = new self ( $ query ) ; $ query -> bindValues ( $ values ) ; return $ query ; }
Select data from a message
18,678
public function send ( $ action , array $ data = array ( ) ) { $ message = array ( 'action' => $ action ) ; if ( count ( $ data ) > 0 ) { $ message [ 'data' ] = $ data ; } $ message = json_encode ( $ message ) ; $ this -> connect ( ) ; $ this -> connection -> writeText ( $ message ) ; $ this -> disconnect ( ) ; return $ this ; }
Connects to the WebSocket server sends a text message and disconnects
18,679
public function isValid ( ) { $ valid = TRUE ; foreach ( $ this -> fields as $ key => $ field ) { if ( $ field -> getOption ( "required" ) && $ field -> getValue ( ) == "" ) { $ this -> errors [ $ key ] = "Requerido" ; $ valid = FALSE ; } if ( isset ( $ this -> validators [ $ key ] ) ) { foreach ( $ this -> validators [ $ key ] as $ validator ) { $ validator -> validate ( $ field ) ; if ( ! $ validator -> isValid ( ) ) { $ this -> errors [ $ key ] = $ validator -> getMessage ( ) ; $ valid = FALSE ; } } } } return $ valid ; }
Verify each field with its correspondant validator if exist .
18,680
public function bind ( $ array ) { foreach ( $ array as $ fieldname => $ value ) { if ( $ this -> getField ( $ fieldname ) != "" ) $ this -> getField ( $ fieldname ) -> setValue ( $ value ) ; } }
Bind each array value with the form field .
18,681
protected function keyOr ( string $ property ) : string { return $ this -> key ? $ this -> key -> find ( ) : $ property ; }
Returns the key if one was provided defaulting to the property name .
18,682
protected function hydrator ( ) : Hydrates { if ( isset ( $ this -> decisionKey ) ) { return $ this -> choiceHydrator ( ) ; } $ mapped = Mapper :: forThe ( $ this -> class ) ; foreach ( $ this -> properties as $ property => $ instruction ) { $ mapped = $ mapped -> property ( $ property , $ instruction ) ; } return $ mapped -> finish ( ) ; }
Produces a mapped hydrator according to the relationship configuration .
18,683
private function choiceHydrator ( ) : Hydrates { assert ( isset ( $ this -> decisionKey ) ) ; return OneOfTheseHydrators :: decideBasedOnThe ( $ this -> decisionKey , array_map ( function ( RepresentsChoice $ choice ) : Hydrates { return $ choice -> finish ( ) ; } , $ this -> choices ) ) ; }
Produces a multiple - choice hydrator .
18,684
public function focus ( $ frameId = null ) { if ( $ frameId instanceof WebDriver_Element ) { $ frameId = $ frameId -> getReference ( ) ; } $ params = [ 'id' => $ frameId ] ; $ command = $ this -> driver -> factoryCommand ( 'frame' , WebDriver_Command :: METHOD_POST , $ params ) ; return $ this -> driver -> curl ( $ command ) [ 'value' ] ; }
Change focus to another frame on the page . If the frame id is null the server should switch to the page s default content .
18,685
public function parent ( ) { $ command = $ this -> driver -> factoryCommand ( 'frame/parent' , WebDriver_Command :: METHOD_POST ) ; return $ this -> driver -> curl ( $ command ) [ 'value' ] ; }
Change focus to the parent context . If the current context is the top level browsing context the context remains unchanged .
18,686
public function generate ( ) : string { $ this -> token = hash ( 'sha256' , $ this -> generateRandomToken ( ) ) ; $ this -> session [ $ this -> name ] = $ this -> token ; return $ this -> token ; }
Generates a token stores it in the set session reference and returns the token
18,687
public static function HashFromInt ( $ num , int $ seed = 5421087 ) : string { $ scrambled = ( 324863748635 * $ num + $ seed ) % 2654348974297586158321 ; $ res = '' ; while ( $ scrambled ) { $ res = self :: BASE62_POOL [ $ scrambled % self :: BASE62_BASE ] . $ res ; $ scrambled = intdiv ( $ scrambled , self :: BASE62_BASE ) ; } $ res = str_repeat ( '0' , 12 - strlen ( $ res ) ) . $ res ; return $ res ; }
Pseudo - random string generator can provide 62^12 unique strings Generated string has length of 12 z char uses to fill generated char to 12 chars length
18,688
public function startScan ( ) { $ this -> scanPaths ( ) ; $ annotations = $ this -> scanFileListForAnnotations ( ) ; $ annotations = collect ( $ annotations ) -> mapWithKeys ( function ( $ annotations , $ className ) { return [ $ className => $ annotations ] ; } ) ; $ this -> setAnnotations ( $ annotations ) ; }
Public method for starting the annotation scanner
18,689
private function scanPaths ( ) { foreach ( Finder :: create ( ) -> files ( ) -> in ( $ this -> pathsToScan ) -> name ( '*.' . $ this -> fileExtension ) as $ file ) { $ this -> fileList -> push ( $ file -> getRealPath ( ) ) ; } }
We create a Finder instance and check for files recursively in the given directories
18,690
private function scanFileListForAnnotations ( ) { $ annotations = [ ] ; foreach ( $ this -> getFileList ( ) as $ file ) { $ this -> classListByFiles [ $ file ] = ClassInformationFromFile :: getClassesFromFile ( $ file ) [ 0 ] ; $ annotations [ $ this -> classListByFiles [ $ file ] ] = $ this -> scanClassForAnnotations ( $ this -> classListByFiles [ $ file ] ) ; } return $ annotations ; }
Collect necessary Namespaces and Class names form the files and do call the annotation scanner on them .
18,691
public function getDisplay ( ) { $ display = $ this -> getServiceLocator ( ) -> get ( 'Config' ) [ 'modules' ] [ 'Grid\User' ] [ 'display' ] ; if ( null !== $ this -> displayRegisterLink ) { $ display [ 'registerLink' ] = ( bool ) $ this -> displayRegisterLink ; } if ( null !== $ this -> displayPasswordRequestLink ) { $ display [ 'passwordRequestLink' ] = ( bool ) $ this -> displayPasswordRequestLink ; } if ( null !== $ this -> displayLoginWithLink ) { $ display [ 'loginWithLink' ] = ( bool ) $ this -> displayLoginWithLink ; } return $ display ; }
Get displayable links
18,692
public function reverse ( ) { $ iterator = new self ( ) ; foreach ( array_reverse ( $ this -> list ) as $ file ) { $ iterator -> add ( $ file ) ; } return $ iterator ; }
get reversed elements .
18,693
public function init ( array $ initial_services = array ( ) , array $ services_providers = array ( ) , array $ services_protected = array ( ) ) { if ( ! is_object ( $ this -> _services ) ) { $ this -> _services = new Collection ( ) ; $ this -> _services_protected = new Collection ( ) ; $ this -> _services_providers = new Collection ( ) ; if ( ! empty ( $ initial_services ) ) { foreach ( $ initial_services as $ _name => $ _service ) { $ this -> setService ( $ _name , $ _service ) ; } } if ( ! empty ( $ services_providers ) ) { foreach ( $ services_providers as $ _name => $ _provider ) { $ this -> setProvider ( $ _name , $ _provider ) ; } } if ( ! empty ( $ services_protected ) ) { foreach ( $ services_protected as $ _name ) { $ this -> setProtected ( $ _name ) ; } } } return $ this ; }
Initialize the service container system
18,694
public function getProvider ( $ name ) { return $ this -> hasProvider ( $ name ) ? $ this -> _services_providers -> offsetGet ( $ name ) : null ; }
Get a service constructor if it exists
18,695
public function isProtected ( $ name ) { return ( bool ) ( $ this -> _services_protected -> offsetExists ( $ name ) && $ this -> _services_protected -> offsetGet ( $ name ) === true ) ; }
Test if a service is protected
18,696
public function unsetService ( $ name ) { if ( $ this -> hasService ( $ name ) ) { if ( ! $ this -> isProtected ( $ name ) ) { if ( $ this -> hasProvider ( $ name ) ) { $ data = $ this -> getProvider ( $ name ) ; if ( is_object ( $ data ) && CodeHelper :: implementsInterface ( $ data , 'Library\ServiceContainer\ServiceProviderInterface' ) ) { $ data -> terminate ( $ this ) ; } } $ this -> _services -> offsetUnset ( $ name ) ; } else { throw new ErrorException ( sprintf ( 'Cannot unset protected service "%s"!' , $ name ) ) ; } } return $ this ; }
Unset a service if it is not protected
18,697
protected function _constructService ( $ name , array $ arguments = array ( ) ) { if ( $ this -> hasProvider ( $ name ) ) { $ data = $ this -> getProvider ( $ name ) ; if ( is_object ( $ data ) && CodeHelper :: implementsInterface ( $ data , 'Library\ServiceContainer\ServiceProviderInterface' ) ) { $ data -> boot ( $ this ) ; $ this -> setService ( $ name , $ data ) ; } elseif ( is_callable ( $ data ) || ( $ data instanceof \ Closure ) ) { try { $ item = call_user_func_array ( $ data , array ( $ this , $ name , $ arguments ) ) ; $ this -> setService ( $ name , $ item ) ; } catch ( \ Exception $ e ) { throw new ErrorException ( sprintf ( 'An error occurred while trying to create a "%s" service!' , $ name ) , 0 , 1 , __FILE__ , __LINE__ , $ e ) ; } } elseif ( is_array ( $ data ) ) { $ this -> setService ( $ name , $ data [ 1 ] , isset ( $ data [ 2 ] ) ? $ data [ 2 ] : false ) ; } else { throw new ErrorException ( sprintf ( 'A "%s" service constructor must be a valid callback!' , $ name ) ) ; } } }
Construct a service based on its constructor item and references it
18,698
private function extractFieldType ( $ spec ) { if ( ! preg_match ( '/(\w+)(?:\s*\(\s*([0-9]+)(?:\,\s*([0-9]+))?\s*\))?(?:\s*(\w+))?/s' , strtoupper ( $ spec ) , $ match ) ) { return [ null , null , null , null ] ; } $ dbType = isset ( $ match [ 1 ] ) ? $ match [ 1 ] : null ; $ size = isset ( $ match [ 2 ] ) && $ match [ 2 ] != '' ? ( int ) $ match [ 2 ] : null ; $ scale = isset ( $ match [ 3 ] ) && $ match [ 2 ] != '' ? ( int ) $ match [ 3 ] : null ; $ unsigned = isset ( $ match [ 4 ] ) && $ match [ 4 ] == 'UNSIGNED' ; return [ $ dbType , $ size , $ scale , $ unsigned ] ; }
Extract a given database field type into field type size scale and unsigned flag .
18,699
public function bind ( $ name , \ Closure $ type ) { $ name = '\\' . ltrim ( $ name , '\\' ) ; $ this -> bindings [ $ name ] = $ type ; }
Adds a new service class .