idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
16,300 | public static function fill ( Grid $ grid , Distribution $ distribution , int $ maxRetries ) { Assert :: assertPositiveInteger ( $ maxRetries , 'maxRetries' ) ; if ( $ distribution -> getCells ( ) !== ( $ cells = $ grid -> rows * $ grid -> columns ) ) { throw new InvalidArgumentException ( "Cannot fill distribution {$d... | Try to fill a tiles distribution randomly within a grid . |
16,301 | public function addMenuItem ( MenuItem $ menuItem , $ position = - 1 ) { if ( ! is_int ( $ position ) ) { throw new InvalidArgumentException ( 'position should be of type int.' ) ; } if ( $ position < 0 ) { $ position = count ( $ this -> menuItems ) ; } $ menuItem -> setOrder ( $ position ) ; Utils :: array_insert ( $ ... | Adds a MenuItem to this Menu . |
16,302 | public function connect ( Application $ app ) { $ ctrl = $ app [ 'controllers_factory' ] ; $ ctrl -> get ( '/' , function ( ) use ( $ app ) { $ root = str_replace ( 'index.php/' , '' , $ app [ 'url_generator' ] -> generate ( 'home' ) ) ; if ( $ app [ 'request' ] -> getRequestURI ( ) != $ root ) { return $ app -> redire... | Silex method that exposes routes to the app |
16,303 | public function getText ( ) { $ args = $ this -> args ; $ msg = $ this -> getMessage ( ) ; return t ( $ msg , $ this -> domain , $ args ) ; } | Get the user s message |
16,304 | public static function from ( UserException $ e , $ field , $ value , $ type = null , $ args = array ( ) ) { return new static ( $ e -> getMessage ( ) , $ field , $ value , $ type , $ e -> getDomain ( ) , $ args ) ; } | Convert an UserException into an InvalidFieldException using other parameters |
16,305 | public function register ( PregDateLexerInterface $ lexer ) { $ this -> regexp .= $ lexer -> getExpression ( ) ; $ this -> lexers [ ] = $ lexer ; } | Registers a pattern in the collection . |
16,306 | protected function compileExpressions ( ) { if ( count ( $ this -> expressions ) === 0 ) { throw new BadMethodCallException ( 'Can\'t compile an empty expression' ) ; } if ( count ( $ this -> expressions ) === 1 ) { return reset ( $ this -> expressions ) ; } $ parts = [ ] ; foreach ( $ this -> expressions as $ expr ) {... | Compile expression list . |
16,307 | function getConnection ( ) { try { if ( is_null ( $ this -> conn ) ) { $ this -> conn = new PDO ( $ this -> getDbDsn ( ) , $ this -> getDbUser ( ) , $ this -> getDbPass ( ) ) ; } return $ this -> conn ; } catch ( PDOException $ e ) { print "Error!: " . $ e -> getMessage ( ) . "<br/>" ; die ( ) ; } } | Open a mysql connection . |
16,308 | public function sendMessage ( $ recipients , $ sender , $ subject , $ templateName , array $ context = array ( ) ) { $ this -> client -> sendMessage ( $ this -> createMessage ( $ recipients , $ sender , $ subject , $ this -> render ( $ templateName , $ context ) ) ) ; } | Send a transactional message using the given template . |
16,309 | public function getInputOptionsSynopsis ( definitions \ Options $ definitions , array $ options = null ) { if ( $ definitions -> isEmpty ( ) ) { return '' ; } if ( $ options [ 'short_synopsis' ] ?? false ) { return '[options]' ; } $ items = [ ] ; foreach ( $ definitions as $ option ) { $ items [ ] = $ this -> getInputO... | Provides a synopsis for the given Input Option Definitions . |
16,310 | public function getInputOptionSynopsis ( input \ Option $ definition , array $ options = null ) { $ shortcut = $ definition -> getShortcut ( ) ? sprintf ( '-%s|' , $ definition -> getShortcut ( ) ) : '' ; if ( $ value = $ definition -> getValue ( ) ) { $ format = $ value -> is ( input \ Value :: REQUIRED ) ? '%s--%s=".... | Provides a synopsis for the given Input Option . |
16,311 | public function getInputArgumentsSynopsis ( definitions \ Arguments $ definitions , array $ options = null ) { if ( $ definitions -> isEmpty ( ) ) { return '' ; } $ items = [ ] ; foreach ( $ definitions as $ argument ) { $ items [ ] = $ this -> getInputArgumentSynopsis ( $ argument , $ options ) ; } return implode ( ' ... | Provides a synopsis for the given Input Argument Definitions . |
16,312 | public function getInputArgumentSynopsis ( input \ Argument $ definition , array $ options = null ) { $ output = '\<' . $ definition -> getName ( ) . '>' ; $ value = $ definition -> getValue ( ) ; if ( ! $ value -> is ( input \ Value :: REQUIRED ) ) { $ output = '[' . $ output . ']' ; } elseif ( $ value instanceof inpu... | Provides a synopsis for the given Input Argument . |
16,313 | public static function getDisplayValue ( $ value ) { switch ( $ value ) { case self :: ACTIVE : return 'Active' ; case self :: ARCHIVED : return 'Archived' ; case self :: PENDING : return 'Pending' ; case self :: CORRUPT : return 'Corrupt' ; default : return $ value ; } } | Data is known to be corrupt |
16,314 | protected function getPWHashFunction ( AbstractData $ data , $ passwordField , $ saltField ) { $ that = $ this ; return function ( Entity $ entity ) use ( $ data , $ passwordField , $ saltField , $ that ) { $ password = $ entity -> get ( $ passwordField ) ; if ( ! $ password ) { return true ; } $ salt = $ entity -> get... | Gets a closure for possibly generating a password hash in the entity . |
16,315 | public function possibleGenSalt ( & $ salt , Entity $ entity , $ saltField ) { if ( ! $ salt ) { $ salt = $ this -> getSalt ( 40 ) ; $ entity -> set ( $ saltField , $ salt ) ; return true ; } return false ; } | Generates a new salt if the given salt is null . |
16,316 | public function doGenerateHash ( AbstractData $ data , Entity $ entity , $ passwordField , $ password , $ newSalt ) { $ doGenerateHash = true ; $ id = $ entity -> get ( 'id' ) ; if ( $ id !== null ) { $ oldEntity = $ data -> get ( $ entity -> get ( 'id' ) ) ; $ doGenerateHash = $ oldEntity -> get ( $ passwordField ) !=... | Determines whether the entity needs a new hash generated . |
16,317 | public function getSalt ( $ len ) { $ chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`~!@#$%^&*()-=_+' ; $ l = strlen ( $ chars ) - 1 ; $ str = '' ; for ( $ i = 0 ; $ i < $ len ; ++ $ i ) { $ str .= $ chars [ mt_rand ( 0 , $ l ) ] ; } return $ str ; } | Generates a random salt of the given length . |
16,318 | public function addEvents ( AbstractData $ data , $ passwordField = 'password' , $ saltField = 'salt' ) { $ that = $ this ; $ saltGenFunction = function ( Entity $ entity ) use ( $ saltField , $ that ) { $ salt = $ that -> getSalt ( 40 ) ; $ entity -> set ( $ saltField , $ salt ) ; return true ; } ; $ data -> getEvents... | Setups CRUDlex with some events so the passwords get salted and hashed properly . |
16,319 | public function append ( SemigroupInterface $ other ) { if ( $ other instanceof static ) { return new static ( array_merge ( $ this -> value , $ other -> value ) ) ; } $ this -> throwMismatchedDataTypeException ( $ other ) ; } | Append another semigroup and return the result . |
16,320 | protected function triggerOnStartup ( ) : AbstractApplication { foreach ( $ this -> getModules ( ) as $ module ) { if ( $ module instanceof StartupProviderInterface ) { $ module -> onStartup ( $ this -> getServiceLocator ( ) ) ; } } return $ this ; } | Trigger startup providers . |
16,321 | protected function triggerOnShutdown ( ) : AbstractApplication { foreach ( $ this -> getModules ( ) as $ module ) { if ( $ module instanceof ShutdownProviderInterface ) { $ module -> onShutdown ( $ this -> getServiceLocator ( ) ) ; } } return $ this ; } | Trigger shutdown providers . |
16,322 | public function pong ( EventInterface $ event , EventQueueInterface $ queue ) { $ params = $ event -> getParams ( ) ; $ queue -> ircPong ( $ params [ 'server1' ] ) ; } | Responds to server ping events . |
16,323 | public static function each ( string $ str , callable $ callable , string $ encoding = null , ... $ args ) : string { if ( $ str === '' ) { return $ str ; } $ result = '' ; $ encoding = $ encoding ? : utils \ Str :: encoding ( $ str ) ; $ length = mb_strlen ( $ str , $ encoding ) ; for ( $ idx = 0 ; $ idx < $ length ; ... | Runs the given callable over each character in the given string and returns the resulting string . |
16,324 | public static function toBinaryString ( string $ character ) : string { $ result = null ; $ length = strlen ( $ character ) ; for ( $ i = 0 ; $ i < $ length ; ++ $ i ) { $ result .= sprintf ( '%08b' , ord ( $ character [ $ i ] ) ) ; } return $ result ; } | Returns the binary string representation of the given character . Multi - byte safe . |
16,325 | public static function toDecimalCode ( string $ character ) : int { $ code = ord ( $ character [ 0 ] ) ; if ( ! ( $ code & 0x80 ) ) { return $ code ; } $ bytes = 1 ; if ( 0xc0 === ( $ code & 0xe0 ) ) { $ code = $ code & ~ 0xc0 ; $ bytes = 2 ; } elseif ( 0xe0 === ( $ code & 0xf0 ) ) { $ code = $ code & ~ 0xe0 ; $ bytes ... | Returns the decimal code representation of the given character . Multi - byte safe . |
16,326 | public function addClass ( DocumentMetadata $ metadata ) : void { $ this -> graph -> addNode ( $ metadata -> name ) ; $ assocNames = $ metadata -> getAssociationNames ( ) ; foreach ( $ assocNames as $ assocName ) { $ targetClass = $ metadata -> getAssociationTargetClass ( $ assocName ) ; $ this -> graph -> addNode ( $ ... | Adds a document class to the dependency graph and evaluates its associations . |
16,327 | public function getOrder ( array $ classNames ) : array { $ elements = array_filter ( iterator_to_array ( $ this -> graph ) , function ( $ element ) use ( $ classNames ) : bool { list ( $ node ) = $ element ; return in_array ( $ node -> getClassName ( ) , $ classNames ) ; } ) ; return array_reverse ( $ elements , false... | Gets the commit order set . |
16,328 | public function setEntities ( array $ entities ) { foreach ( $ entities as $ entity ) { if ( ! $ entity instanceof AbstractEntity ) { $ message = sprintf ( 'Expected an array of entities. Array contains element of type %s.' , gettype ( $ entity ) ) ; throw new InvalidArgumentException ( $ message ) ; } } $ this -> enti... | Set the entities wrapped by this class |
16,329 | public function getArrayCopy ( ) { $ results = array_map ( function ( $ entity ) { return $ entity -> getArrayCopy ( ) ; } , $ this -> entities ) ; if ( ! $ this -> paginationData ) { return $ results ; } else { $ data = $ this -> paginationData -> getArrayCopy ( ) ; $ data [ 'results' ] = $ results ; return $ data ; }... | Return an array representation of the object |
16,330 | private function setAccessControllers ( ) : void { $ this -> absolutePathToAccessControllers = [ ] ; $ route = $ this -> routingBasePath ; foreach ( $ this -> getRealArgs ( ) as $ arg ) { $ route .= $ arg . '/' ; $ path = $ route . 'access.php' ; if ( \ is_file ( $ path ) ) { array_unshift ( $ this -> absolutePathToAcc... | Set the access controller closures . |
16,331 | private function createRoute ( ) : void { $ this -> virtualArgs = [ ] ; $ this -> realArgs = \ explode ( '/' , $ this -> url ) ; do { if ( $ this -> setMainController ( $ this -> routingBasePath . implode ( '/' , $ this -> realArgs ) ) ) return ; array_unshift ( $ this -> virtualArgs , array_pop ( $ this -> realArgs ) ... | Calculate the route and route parameters . |
16,332 | private function setMainController ( string $ route ) : bool { if ( ! \ is_dir ( $ route ) ) return false ; foreach ( $ this -> requestNames [ $ this -> requestType ] as $ requestName ) { $ path = $ route . '/' . $ requestName ; if ( \ is_file ( $ path ) ) { $ this -> absolutePathToMainController = $ path ; return true... | Set the main controller closure to the most fitting controller . |
16,333 | public function pop ( interfaces \ Style $ searched = null ) : interfaces \ Style { if ( empty ( $ this -> styles ) ) { return $ this -> default ; } if ( ! isset ( $ searched ) ) { return array_pop ( $ this -> styles ) ; } foreach ( array_reverse ( $ this -> styles , true ) as $ index => $ stackedStyle ) { if ( $ searc... | Pops a style from the Stack . |
16,334 | public function current ( ) : interfaces \ Style { return ! empty ( $ this -> styles ) ? end ( $ this -> styles ) : $ this -> default ; } | Returns the current topmost Style in the stack or the default Style if none is stacked . |
16,335 | public function requestUrl ( ApiResourceInterface $ resource ) { $ resourcePath = $ this -> resourcePath ( ) . '/' . $ this -> getResourceId ( ) ; return $ resource -> apiUrl ( $ resourcePath ) ; } | HTTP request URL . |
16,336 | public static function postInstall ( Event $ event ) { $ vendor_dir = $ event -> getComposer ( ) -> getConfig ( ) -> get ( 'vendor-dir' ) ; $ base_dir = dirname ( $ vendor_dir ) ; $ config_file = $ base_dir . '/config/public_vendor.json' ; $ gitignore_file = $ base_dir . '/.gitignore' ; if ( file_exists ( $ config_file... | Callback for Composer s post - install - cmd |
16,337 | public static function getSubPath ( $ pFileName , $ pDepth = 3 ) { if ( empty ( $ pFileName ) ) { return DS ; } $ levels = array ( ) ; for ( $ i = 0 ; $ i < $ pDepth ; $ i ++ ) { $ levels [ ] = substr ( $ pFileName , $ i , 1 ) ; } return implode ( DS , $ levels ) . DS ; } | Create a path to store files in multiple subdirectories based on first letters of filename . |
16,338 | public static function write ( $ pFile , $ pContent , $ pAppend = false ) { if ( ! is_writable ( $ pFile ) ) { self :: create ( $ pFile ) ; } if ( $ pAppend ) { return ( file_put_contents ( $ pFile , $ pContent , FILE_APPEND | LOCK_EX ) ) ; } return ( file_put_contents ( $ pFile , $ pContent , LOCK_EX ) ) ; } | Write content to a file . |
16,339 | public static function chmod ( $ pFile , $ pMode ) { if ( strpos ( $ pMode , '0' ) !== 0 ) { $ mode = octdec ( '0' . $ pMode ) ; } else { $ mode = octdec ( $ pMode ) ; } return chmod ( $ pFile , $ mode ) ; } | CHMOD a file . |
16,340 | public function withCallback ( callable $ theCallback ) { $ copy = clone $ this ; foreach ( $ this -> states as $ key => $ s ) { foreach ( $ s -> conditions as $ c ) { if ( $ c -> nextState === State :: MATCH_FOUND ) { $ copy -> callbacks [ $ key ] [ State :: MATCH_FOUND ] = $ theCallback ; } } } return $ copy ; } | Set the pattern s match callback |
16,341 | public static function getParent ( $ className ) { $ reflection = ClassType :: from ( $ className ) ; $ parent = $ reflection -> getParentClass ( ) ; return $ parent ? $ parent -> getName ( ) : $ parent ; } | Get parent class |
16,342 | public function getData ( ) { $ values = array_filter ( filter_input_array ( INPUT_POST ) ) ; foreach ( $ values as $ key => $ value ) { if ( is_array ( $ value ) ) { $ values [ $ key ] = array_filter ( $ value ) ; } } return $ values + $ _FILES ; } | Devuelve todos losd atos enviados de un formulario |
16,343 | public function is ( $ method ) { $ m = strtolower ( $ method ) ; if ( ( $ m == 'post' || $ m == 'ajax' ) && $ this -> _method == 'ajax-post' ) { return TRUE ; } return $ m == $ this -> _method ; } | Verifica el tipo de request dado |
16,344 | public function data ( $ name , $ filter = FILTER_DEFAULT , $ flag = NULL ) { $ data = $ flag ? filter_input ( INPUT_POST , $ name , $ filter , $ flag ) : filter_input ( INPUT_POST , $ name , $ filter ) ; return $ data ; } | Devuelve el dato enviado por POST |
16,345 | public function url ( $ name ) { if ( key_exists ( $ name , $ this -> _url ) ) { return $ this -> _url [ $ name ] ; } return htmlentities ( utf8_decode ( filter_input ( INPUT_GET , $ name , FILTER_SANITIZE_STRING ) ) ) ; } | Devuelve el dato enviado por GET |
16,346 | public function cookie ( $ name ) { if ( in_array ( $ name , $ this -> cookies ) ) { return filter_input ( INPUT_COOKIE , $ name , FILTER_SANITIZE_STRING ) ; } return NULL ; } | Devuelve el dato de una COOKIE |
16,347 | public function aliasSet ( $ value ) { $ columns = $ this -> getColumns ( ) ; $ this -> aliasGet ( $ oldValue ) ; foreach ( $ columns as & $ column ) { $ tableAlias = $ column [ 0 ] ; if ( $ tableAlias === $ oldValue ) { $ column [ 0 ] = $ value ; } } $ select = $ this -> getSelect ( ) ; $ from = $ select -> getPart ( ... | Replaces current alias with different one . |
16,348 | public function deleteBy ( $ condition = null ) { if ( ! is_null ( $ condition ) ) { $ this -> filterBy ( $ condition ) ; } $ matched = $ this -> load ( ) ; array_each ( $ matched , function ( $ model ) { $ model -> delete ( ) ; } ) ; return ! empty ( $ matched ) ; } | Delete records by specified conditions . |
16,349 | public function beforePrepare ( Event $ event ) { $ command = $ event [ 'command' ] ; $ operation = $ command -> getOperation ( ) ; $ client = $ command -> getClient ( ) ; if ( $ command -> getName ( ) !== 'updateEntity' ) return ; if ( $ operation -> getParam ( 'collection' ) -> getDefault ( ) !== 'user' ) return ; $ ... | Map Laravel s soft delete action to Kinvey s user suspend endpoint . |
16,350 | public function getProcess ( $ pid = null ) { if ( is_null ( $ pid ) ) { $ pid = $ this -> pid ; } if ( is_null ( $ pid ) ) { throw new ProcessFinderException ( 'Pid is required' ) ; } $ process = $ this -> api -> getProcessByPid ( $ pid ) ; return count ( $ process ) ? $ process [ 0 ] : false ; } | If the process exists will return the array else if not found will return false . |
16,351 | public function getRouteName ( $ resourceName = null , $ action ) { $ resourceName = $ resourceName ?? $ this -> resourceName ; return $ this -> alias . $ resourceName . '.' . $ action ; } | Get route name for the specified resource and action . |
16,352 | public function getViewsLocation ( $ resourceName = null ) { $ resourceName = $ resourceName ?? $ this -> resourceName ; return $ this -> module . $ this -> theme . $ resourceName ; } | Get views location for the specified resource . |
16,353 | public function getVendorViewsLocation ( $ resourceName = null ) { $ resourceName = $ resourceName ?? $ this -> resourceName ; if ( $ this -> package ) { $ package = str_finish ( $ this -> package , '.' ) ; } return 'vendor.' . $ package . $ this -> theme . $ resourceName ; } | Get vendor views location for the specified resource . |
16,354 | protected function loadModulePath ( $ path , $ locale , $ name , $ author ) { if ( $ this -> files -> exists ( $ full = "{$path}/{$author}/{$name}/translate/{$locale}.php" ) ) { return $ this -> files -> getRequire ( $ full ) ; } return [ ] ; } | load module file translated |
16,355 | public function loadModule ( $ locale , $ name , $ author ) { if ( isset ( $ this -> hints [ 'Modules' ] ) ) { return $ this -> loadModulePath ( $ this -> hints [ 'Modules' ] , $ locale , $ name , $ author ) ; } return [ ] ; } | get file from modules |
16,356 | public function run ( $ argv ) { $ args = $ this -> getArgs ( $ argv ) ; if ( array_key_exists ( $ args [ 1 ] , $ this -> commands ) ) { $ callback = $ this -> commands [ $ args [ 1 ] ] ; $ args = array_slice ( $ args , 2 ) ; if ( is_callable ( $ callback ) ) { return $ this -> injectionClosure ( $ callback , $ args ) ... | Match and run a command line . |
16,357 | public function getLibSrc ( $ ver ) { if ( ! $ this -> isValidVersion ( $ ver ) ) { throw new \ Exception ( sprintf ( 'Invalid library version provided "%s"' , $ ver ) ) ; } $ options = $ this -> options ; $ cdnUrl = rtrim ( $ options [ 'cdn-base' ] , '/' ) . '/' . trim ( $ options [ 'cdn-subfolder' ] , '/' ) . '/' . $... | Get src to library for specific version |
16,358 | public function generateTableOptions ( Table $ table ) { $ code = [ ] ; $ options = $ table -> getOptions ( ) ; $ code = $ this -> valuetize ( $ options ) ; return $ code === '[]' ? '' : ', ' . $ code ; } | generate table options |
16,359 | public function generateColumnOptions ( Column $ column ) { $ options = [ ] ; $ keys = [ 'length' , 'default' , 'collation' , 'null' , 'precision' , 'scale' , 'after' , 'update' , 'comment' ] ; foreach ( $ keys as $ key ) { $ method = "get{$key}" ; if ( $ key === 'length' ) $ method = 'getLimit' ; $ value = $ column ->... | generate column options |
16,360 | public function isSinglePrimaryKeyColumn ( Table $ table , Column $ column ) { $ options = $ table -> getOptions ( ) ; if ( ! $ options && $ column -> getName ( ) === 'id' ) return true ; if ( isset ( $ options [ 'id' ] ) && $ options [ 'id' ] == $ column -> getName ( ) ) return true ; return false ; } | is single primary key column ? |
16,361 | protected function createFactory ( ) { if ( ! class_exists ( $ this -> factoryClass ) ) { throw new RuntimeException ( sprintf ( 'Failed to create an instance of non-existing factory class "%s".' , $ this -> factoryClass ) ) ; } $ class = $ this -> factoryClass ; switch ( count ( $ this -> args ) ) { case 0 : $ factory... | Create the factory on demand |
16,362 | public static function stripAttributes ( $ routeString , & $ route , $ withParameters = true ) { $ route [ 'query' ] = [ ] ; $ route [ 'fragment' ] = '' ; $ route [ 'parameters' ] = [ ] ; $ regex = '/^(.*?)(?:\?([^?#]*))?(?:#([^#?]*))?$/' ; preg_match ( $ regex , $ routeString , $ matches ) ; if ( isset ( $ matches [ 2... | Strip fragment query and optionally parameters from a route string . |
16,363 | protected function _assignDefinitionContainer ( callable $ definition , BaseContainerInterface $ container ) { return function ( BaseContainerInterface $ c ) use ( $ definition , $ container ) { $ args = func_get_args ( ) ; $ args [ 0 ] = $ container ; return $ this -> _invokeCallable ( $ definition , $ args ) ; } ; } | Wraps the given definition such that it will receive the given container . |
16,364 | public function perform ( ) { $ app = $ this -> application ( ) ; $ command = $ this -> getConsoleCommand ( $ app ) ; $ inputDefinition = $ this -> getInputDefinition ( $ this -> args ) ; $ input = new ArrayInput ( $ this -> args , $ inputDefinition ) ; $ output = new ConsoleOutput ; try { $ command -> run ( $ input , ... | Manually load configure and run the console command |
16,365 | protected function application ( ) { $ applicationInitializer = new ApplicationInitializer ; $ app = $ applicationInitializer -> initialize ( ) ; $ defaultServices = new \ Synapse \ Application \ Services ; $ defaultServices -> register ( $ app ) ; $ appServices = new \ Application \ Services ; $ appServices -> registe... | Return the Silex application loaded with all routes and services |
16,366 | protected function getInputDefinition ( array $ args ) { $ definition = new InputDefinition ( ) ; foreach ( $ args as $ field => $ value ) { $ definition -> addArgument ( new InputArgument ( $ field ) ) ; } return $ definition ; } | Get an InputDefinition formed by the arguments provided |
16,367 | protected function initializeConfig ( array $ config = null ) { $ default = $ this -> defaultConfigurations ( ) ; $ this -> config = $ config ? array_replace_recursive ( $ default , $ config ) : $ default ; } | Overrides default configurations with user supplied values . |
16,368 | protected function getTotalOfRecordsString ( int $ totalOfRecords , array $ data ) { $ show = $ data [ 'show' ] ; $ page = $ data [ 'page' ] ; $ startRecord = 0 ; if ( intval ( $ totalOfRecords ) > 0 ) { $ startRecord = ( $ show * ( $ page - 1 ) ) + 1 ; } $ endRecord = $ show * $ page ; if ( $ endRecord > $ totalOfReco... | Calculates the total of records string |
16,369 | public function setPath ( $ path ) { if ( ! is_readable ( $ path ) ) { throw new \ InvalidArgumentException ( 'The passed path is not readable: ' . $ path ) ; } $ this -> path = $ path ; $ this -> source = file_get_contents ( $ path ) ; return $ this ; } | Set the path to the source file . |
16,370 | public function getOutputFilename ( $ prefix = null ) { $ fileInfo = $ this -> getFileInformation ( ) ; $ filename = str_replace ( '/' , '_' , $ fileInfo -> getPathname ( ) ) ; if ( null !== $ prefix ) { $ filename = substr ( $ filename , strlen ( $ prefix ) ) ; } return strtr ( ltrim ( $ filename , '_' ) , array ( '.'... | Get the name for this Pinocchio s output file . |
16,371 | protected static function parseResourceBundle ( $ p_rb , $ p_prefix = '' ) { $ p_prefix = rtrim ( $ p_prefix , '.' ) ; $ values = array ( ) ; if ( $ p_rb instanceof \ ResourceBundle ) { foreach ( $ p_rb as $ k => $ v ) { if ( is_object ( $ v ) ) { $ temp = self :: parseResourceBundle ( $ v , ( $ p_prefix == '' ? '' : $... | Parse des ressources |
16,372 | public static function getAsArray ( $ p_name , $ p_path , $ p_prefix = '' ) { $ ressource = new \ ResourceBundle ( $ p_name , $ p_path ) ; $ arr = self :: parseResourceBundle ( $ ressource , $ p_prefix ) ; return $ arr ; } | Retourne les traductions sous forme de tableau |
16,373 | protected function getMethodNotAllowedResponse ( MethodNotAllowed $ exception ) : ResponseInterface { return ( new Response ( ) ) -> withStatusCode ( 405 ) -> withHeader ( 'Allow' , implode ( ', ' , $ exception -> getAllowedMethods ( ) ) ) -> withBody ( [ 'type' => '' , 'title' => 'Method not allowed.' , 'method' => $ ... | Get response for MethodNotAllowed exception . |
16,374 | protected function getNotFoundResponse ( NotFound $ exception ) : ResponseInterface { return ( new Response ( ) ) -> withStatusCode ( 404 ) -> withBody ( [ 'type' => '' , 'title' => 'Not found.' , 'path' => $ exception -> getRequest ( ) -> getUri ( ) -> toRelative ( ) , ] ) ; } | Get response for NotFound exception . |
16,375 | protected function getInvalidQueryStringResponse ( InvalidQueryString $ exception ) : ResponseInterface { return ( new Response ( ) ) -> withStatusCode ( 400 ) -> withBody ( [ 'type' => '' , 'title' => 'Invalid query string.' , 'parameter' => $ exception -> getParameter ( ) , 'reason' => $ exception -> getResult ( ) , ... | Get response for InvalidQueryString exception . |
16,376 | public function getText ( $ key ) { if ( isset ( $ this -> data [ $ key ] ) ) { return $ this -> data [ $ key ] ; } return $ key ; } | Returns a language string by looking for a matching key |
16,377 | public function save ( $ uri = null , $ className = null , $ extraHeaders = array ( ) ) { return $ this -> getService ( ) -> updateEntry ( $ this , $ uri , $ className , $ extraHeaders ) ; } | Uploads changes in this entry to the server using Zend_Gdata_App |
16,378 | public function reload ( $ uri = null , $ className = null , $ extraHeaders = array ( ) ) { $ editLink = $ this -> getEditLink ( ) ; if ( ( $ uri === null ) && $ editLink != null ) { $ uri = $ editLink -> getHref ( ) ; } if ( $ className === null ) { $ className = get_class ( $ this ) ; } if ( $ this -> _etag != null &... | Reload the current entry . Returns a new copy of the entry as returned by the server or null if no changes exist . This does not modify the current entry instance . |
16,379 | protected static function cleanFields ( $ fields ) { $ new = [ ] ; $ fieldList = explode ( ',' , $ fields ) ; foreach ( $ fieldList as $ f ) { if ( static :: ID_FIELD !== trim ( strtolower ( $ f ) ) ) { $ new [ ] = $ f ; } } return implode ( ',' , $ new ) ; } | Excluding _id field from field list |
16,380 | protected function preCleanRecords ( $ records ) { $ new = [ ] ; foreach ( $ records as $ record ) { if ( property_exists ( $ record , $ this -> transactionTable ) ) { $ cleaned = ( array ) $ record -> { $ this -> transactionTable } ; unset ( $ cleaned [ static :: ID_FIELD ] ) ; if ( property_exists ( $ record , '_id' ... | Cleaning Couchbase rows . |
16,381 | protected static function isExpression ( $ field ) { $ alias = explode ( ' as ' , $ field ) ; $ field = trim ( $ alias [ 0 ] ) ; if ( preg_match ( '/\S+\(\S*\)/' , $ field ) === 1 ) { if ( isset ( $ alias [ 1 ] ) ) { return trim ( $ alias [ 1 ] ) ; } return true ; } return false ; } | Checks to see if field is an expression |
16,382 | private function find ( $ id ) { if ( ! isset ( $ this -> registry [ $ id ] ) ) { throw new NotFoundException ( "Entry id '" . $ id . "' not found in container" ) ; } return $ this -> registry [ $ id ] ; } | Find the item in the registry |
16,383 | public function enabled ( $ name = null ) { if ( empty ( $ this -> _providers ) ) { $ this -> _providers = ( array ) Configure :: read ( 'Opauth.Strategy' ) ; } if ( empty ( $ this -> _providers ) ) { return false ; } if ( ! empty ( $ name ) ) { return isset ( $ this -> _providers [ $ name ] ) ; } return $ this -> _pro... | Check if a given provider s strategy is enabled . |
16,384 | public function isAuthenticated ( $ authData ) { if ( ! empty ( $ this -> _user ) ) { $ this -> updateData ( $ this -> mapData ( $ authData ) ) ; return $ this -> _user ; } $ Model = ClassRegistry :: init ( $ this -> _authenticateObject -> settings [ 'userModel' ] ) ; $ conditions = array ( $ Model -> alias . '.' . Inf... | Checks if OAuth2 user authenticates to local user base . |
16,385 | public function mapData ( $ authData ) { $ map = $ this -> mapKeysToFields ; list ( , $ model ) = pluginSplit ( $ this -> _authenticateObject -> settings [ 'userModel' ] ) ; $ provider = Inflector :: underscore ( $ authData [ 'provider' ] ) ; $ data = array ( $ model => array ( $ provider . '_credentials' => serialize ... | Maps Opauth s data for use in models . |
16,386 | public function patch ( Request $ request , Fractal $ fractal , InputGateContract $ inputGate ) { $ this -> beforeRequest ( $ request , func_get_args ( ) ) ; $ id = $ this -> parseObjectId ( $ request ) ; $ model = $ this -> loadAuthorizeObject ( $ id , 'update' ) ; $ input = $ request -> json ( ) -> all ( ) ; if ( ! i... | Update the object |
16,387 | public function createAndSave ( $ create_vars = [ ] ) { $ new_model = $ this -> create ( $ create_vars ) ; $ model = $ this -> save ( $ new_model ) ; return $ model ; } | creates a new model |
16,388 | public function create ( $ create_vars = [ ] ) { $ new_model_doc_vars = array_merge ( $ this -> newModelDefaults ( ) , $ create_vars ) ; $ new_model_doc_vars = $ this -> onCreate_pre ( $ new_model_doc_vars ) ; return $ this -> newModel ( $ new_model_doc_vars ) ; } | creates a model without saving to the database |
16,389 | public function save ( BaseMysqlModel $ model ) { $ create_vars = $ this -> onSave_pre ( ( array ) $ model ) ; $ sql = $ this -> buildInsertStatement ( $ create_vars ) ; $ id = $ this -> connection_manager -> executeWithReconnect ( function ( $ mysql_dbh ) use ( $ sql , $ create_vars ) { $ sth = $ mysql_dbh -> prepare ... | saves a new model to the database |
16,390 | public function findByID ( $ model_or_id , $ options = null ) { $ id = $ this -> extractID ( $ model_or_id ) ; return $ this -> findOne ( [ 'id' => $ id ] , null , $ options ) ; } | finds a model by ID |
16,391 | public function findOne ( $ vars , $ order_by_keys = null , $ options = null ) { foreach ( $ this -> find ( $ vars , $ order_by_keys , 1 , $ options ) as $ model ) { return $ model ; } return null ; } | queries the database for a single object |
16,392 | public function update ( $ model_or_id , $ update_vars , $ mongo_options = [ ] ) { $ id = $ this -> extractID ( $ model_or_id ) ; $ update_vars = $ this -> onUpdate_pre ( $ update_vars , $ model_or_id ) ; $ sql = $ this -> buildUpdateStatement ( $ update_vars , [ 'id' ] ) ; $ sth = $ this -> connection_manager -> execu... | updates a model in the database |
16,393 | public static function createFromParts ( array $ parts , $ timezone = null ) { $ year = isset ( $ parts [ 0 ] ) ? $ parts [ 0 ] : date ( 'Y' ) ; $ month = isset ( $ parts [ 1 ] ) ? $ parts [ 1 ] : date ( 'm' ) ; $ day = isset ( $ parts [ 2 ] ) ? $ parts [ 2 ] : date ( 'd' ) ; $ hour = isset ( $ parts [ 3 ] ) ? $ parts ... | Create a new DateTime instance from a specific parts of date and time . |
16,394 | private function next ( $ dayOfWeek ) { $ days = [ self :: SUNDAY => 'Sunday' , self :: MONDAY => 'Monday' , self :: TUESDAY => 'Tuesday' , self :: WEDNESDAY => 'Wednesday' , self :: THURSDAY => 'Thursday' , self :: FRIDAY => 'Friday' , self :: SATURDAY => 'Saturday' , ] ; $ dow = $ days [ $ dayOfWeek ] ; return $ this... | Modify to the next occurrence of a given day of the week . |
16,395 | private static function localeFormat ( $ part = 'datetime' ) { if ( self :: $ localeFormat === null ) { $ locale = self :: getLocale ( ) ; $ file = resource_path ( 'lang/' . $ locale . '/datetime.php' ) ; if ( file_exists ( $ file ) ) { self :: $ localeFormat = include $ file ; } else { $ file = resource_path ( 'lang/'... | Returns the locale date time format . |
16,396 | private function parseDiscriminatorField ( $ discriminatorField ) { if ( is_string ( $ discriminatorField ) ) { return $ discriminatorField ; } if ( ! is_array ( $ discriminatorField ) ) { throw new \ InvalidArgumentException ( 'Expected array or string for discriminatorField; found: ' . gettype ( $ discriminatorField ... | Parses the class or field - level discriminatorField option . |
16,397 | static function gaeutilJson ( $ project_directory , $ app_engine_project , $ gaeutil_defaults = [ ] ) { $ config_dir_location = Conf :: getConfFolderPath ( $ project_directory ) ; $ gaeutil_json_location = Conf :: getGaeUtilJsonPath ( $ project_directory ) ; Files :: ensureDirectory ( $ config_dir_location ) ; $ gaeuti... | Fixing gaeutil . json |
16,398 | static function packageJson ( $ project_directory , $ app_engine_project , $ app_engine_service , $ package_json_defaults = [ ] ) { $ package_json_location = $ project_directory . DIRECTORY_SEPARATOR . "package.json" ; $ package_json_content = Files :: getJson ( $ package_json_location , [ ] ) ; $ package_json_content ... | Fixing package . json |
16,399 | private function info ( ) { $ response = [ 'class' => [ ] ] ; foreach ( $ this -> config [ "classes" ] as $ key => $ val ) { $ response [ "class" ] [ $ key ] [ "config" ] = ! empty ( $ val [ 1 ] ) ? $ val [ 1 ] : [ ] ; if ( ! file_exists ( $ val [ 0 ] ) ) { $ response [ "class" ] [ $ key ] [ "methods" ] = [ ] ; continu... | Return info about available classes |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.