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' ] =... | 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 ] ; } } ) -> col... | 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 ( ) -> g... | 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'... | 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_sh... | 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 ( ! @ $... | 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 $ ... | 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 -... | 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 , ... | 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 ) ; $ messa... | 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 ] ] ; }... | 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 = ... | 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 ) ; } $ filte... | 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... | 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 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... | 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 ( ) ;... | 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 [ 'filenam... | 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 -> ... | 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... | 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 ( 'fail... | 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 $... | 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 =... | 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_callabl... | 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 ) { r... | 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=... | 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 ( $ committedVersi... | 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 =... | 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' ] ... | 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 ( $ cl... | 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 -> getClassNa... | 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 (... | 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... | 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 ... | 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 ... | 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 $ ma... | 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 ( $ com... | 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_B... | 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 ... | 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 ) { ... | 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 = n... | 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\Service... | 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 ( $ t... | 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 ... | 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 . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.