idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
36,400 | public function terminate ( SymfonyRequest $ request , SymfonyResponse $ response ) { $ this -> callFinishCallbacks ( $ request , $ response ) ; $ this -> shutdown ( ) ; } | Terminate the request and send the response to the browser . |
36,401 | public function callFinishCallbacks ( SymfonyRequest $ request , SymfonyResponse $ response ) { foreach ( $ this -> finishCallbacks as $ callback ) { call_user_func ( $ callback , $ request , $ response ) ; } } | Call the finish callbacks assigned to the application . |
36,402 | public function prepareRequest ( Request $ request ) { if ( ! is_null ( $ this [ 'config' ] [ 'session.driver' ] ) && ! $ request -> hasSession ( ) ) { $ request -> setSession ( $ this [ 'session' ] -> driver ( ) ) ; } return $ request ; } | Prepare the request by injecting any services . |
36,403 | public function prepareResponse ( $ value ) { if ( ! $ value instanceof SymfonyResponse ) $ value = new Response ( $ value ) ; return $ value -> prepare ( $ this [ 'request' ] ) ; } | Prepare the given value as a Response object . |
36,404 | public function missing ( Closure $ callback ) { $ this -> error ( function ( NotFoundHttpException $ e ) use ( $ callback ) { return call_user_func ( $ callback , $ e ) ; } ) ; } | Register a 404 error handler . |
36,405 | public function fatal ( Closure $ callback ) { $ this -> error ( function ( FatalErrorException $ e ) use ( $ callback ) { return call_user_func ( $ callback , $ e ) ; } ) ; } | Register an error handler for fatal errors . |
36,406 | public function create ( Package $ package , $ path , $ plain = true ) { $ directory = $ this -> createDirectory ( $ package , $ path ) ; foreach ( $ this -> getBlocks ( $ plain ) as $ block ) { $ this -> { "write{$block}" } ( $ package , $ directory , $ plain ) ; } return $ directory ; } | Create a new package stub . |
36,407 | public function writeSupportFiles ( Package $ package , $ directory , $ plain ) { foreach ( array ( 'PhpUnit' , 'Travis' , 'Composer' , 'Ignore' ) as $ file ) { $ this -> { "write{$file}File" } ( $ package , $ directory , $ plain ) ; } } | Write the support files to the package root . |
36,408 | protected function writePhpUnitFile ( Package $ package , $ directory ) { $ stub = __DIR__ . '/stubs/phpunit.xml' ; $ this -> files -> copy ( $ stub , $ directory . '/phpunit.xml' ) ; } | Write the PHPUnit stub file . |
36,409 | protected function writeComposerFile ( Package $ package , $ directory , $ plain ) { $ stub = $ this -> getComposerStub ( $ plain ) ; $ stub = $ this -> formatPackageStub ( $ package , $ stub ) ; $ this -> files -> put ( $ directory . '/composer.json' , $ stub ) ; } | Write the Composer . json stub file . |
36,410 | protected function getComposerStub ( $ plain ) { if ( $ plain ) return $ this -> files -> get ( __DIR__ . '/stubs/plain.composer.json' ) ; return $ this -> files -> get ( __DIR__ . '/stubs/composer.json' ) ; } | Get the Composer . json stub file contents . |
36,411 | public function writeIgnoreFile ( Package $ package , $ directory , $ plain ) { $ this -> files -> copy ( __DIR__ . '/stubs/gitignore.txt' , $ directory . '/.gitignore' ) ; } | Write the stub . gitignore file for the package . |
36,412 | public function writeSupportDirectories ( Package $ package , $ directory ) { foreach ( array ( 'config' , 'controllers' , 'lang' , 'migrations' , 'views' ) as $ support ) { $ this -> writeSupportDirectory ( $ package , $ support , $ directory ) ; } } | Create the support directories for a package . |
36,413 | protected function writeSupportDirectory ( Package $ package , $ support , $ directory ) { $ path = $ directory . '/src/' . $ support ; $ this -> files -> makeDirectory ( $ path , 0777 , true ) ; $ this -> files -> put ( $ path . '/.gitkeep' , '' ) ; } | Write a specific support directory for the package . |
36,414 | public function writePublicDirectory ( Package $ package , $ directory , $ plain ) { if ( $ plain ) return ; $ this -> files -> makeDirectory ( $ directory . '/public' ) ; $ this -> files -> put ( $ directory . '/public/.gitkeep' , '' ) ; } | Create the public directory for the package . |
36,415 | public function writeServiceProvider ( Package $ package , $ directory , $ plain ) { $ stub = $ this -> getProviderStub ( $ package , $ plain ) ; $ this -> writeProviderStub ( $ package , $ directory , $ stub ) ; } | Write the stub ServiceProvider for the package . |
36,416 | protected function writeProviderStub ( Package $ package , $ directory , $ stub ) { $ path = $ this -> createClassDirectory ( $ package , $ directory ) ; $ file = $ path . '/' . $ package -> name . 'ServiceProvider.php' ; $ this -> files -> put ( $ file , $ stub ) ; } | Write the service provider stub for the package . |
36,417 | protected function getProviderStub ( Package $ package , $ plain ) { return $ this -> formatPackageStub ( $ package , $ this -> getProviderFile ( $ plain ) ) ; } | Get the stub for a ServiceProvider . |
36,418 | protected function getProviderFile ( $ plain ) { if ( $ plain ) { return $ this -> files -> get ( __DIR__ . '/stubs/plain.provider.stub' ) ; } else { return $ this -> files -> get ( __DIR__ . '/stubs/provider.stub' ) ; } } | Load the raw service provider file . |
36,419 | protected function createClassDirectory ( Package $ package , $ directory ) { $ path = $ directory . '/src/' . $ package -> vendor . '/' . $ package -> name ; if ( ! $ this -> files -> isDirectory ( $ path ) ) { $ this -> files -> makeDirectory ( $ path , 0777 , true ) ; } return $ path ; } | Create the main source directory for the package . |
36,420 | protected function formatPackageStub ( Package $ package , $ stub ) { foreach ( get_object_vars ( $ package ) as $ key => $ value ) { $ stub = str_replace ( '{{' . snake_case ( $ key ) . '}}' , $ value , $ stub ) ; } return $ stub ; } | Format a generic package stub file . |
36,421 | protected function createDirectory ( Package $ package , $ path ) { $ fullPath = $ path . '/' . $ package -> getFullName ( ) ; if ( ! $ this -> files -> isDirectory ( $ fullPath ) ) { $ this -> files -> makeDirectory ( $ fullPath , 0777 , true ) ; return $ fullPath ; } throw new \ InvalidArgumentException ( "Package exists." ) ; } | Create a workbench directory for the package . |
36,422 | public function registerSwordEngine ( $ resolver ) { $ app = $ this -> app ; $ app -> bindShared ( 'sword.compiler' , function ( $ app ) { $ cache = $ app [ 'path.storage' ] . '/views' ; return new SwordCompiler ( $ app [ 'files' ] , $ cache ) ; } ) ; $ resolver -> register ( 'sword' , function ( ) use ( $ app ) { return new CompilerEngine ( $ app [ 'sword.compiler' ] , $ app [ 'files' ] ) ; } ) ; } | Register the Sword engine implementation . |
36,423 | public function addItem ( $ item ) { $ indentation = $ this -> indent ( $ this -> indentation ) ; $ this -> buffer [ ] = $ indentation . $ item ; } | Add content to be formated . |
36,424 | public static function forceString ( $ value ) { if ( is_string ( $ value ) ) { return [ sprintf ( "'%s'" , $ value ) , [ ] ] ; } if ( is_array ( $ value ) ) { $ import = [ ] ; $ assoc = [ ] ; foreach ( $ value as $ key => $ val ) { if ( ! is_int ( $ key ) ) { $ key_arr = static :: forceString ( $ key ) ; $ val_arr = static :: forceString ( $ val ) ; array_push ( $ assoc , sprintf ( '%1$s=> %2$s' , $ key_arr [ 0 ] , $ val_arr [ 0 ] ) ) ; if ( ! empty ( $ key_arr [ 1 ] ) ) { $ import = array_merge ( $ import , $ key_arr [ 1 ] ) ; } if ( ! empty ( $ val_arr [ 1 ] ) ) { $ import = array_merge ( $ import , $ val_arr [ 1 ] ) ; } } else { $ val_arr = static :: forceString ( $ val ) ; array_push ( $ assoc , $ val_arr [ 0 ] ) ; if ( ! empty ( $ val_arr [ 1 ] ) ) { $ import = array_merge ( $ import , $ val_arr [ 1 ] ) ; } } } return [ sprintf ( '[%s]' , implode ( ', ' , $ assoc ) ) , $ import ] ; } if ( is_object ( $ value ) && $ value instanceof DeConstructableInterface ) { $ skel = $ value -> deconstruct ( ) ; $ import = [ $ skel [ 'path' ] ] ; $ class = $ skel [ 'name' ] ; $ constructor_args = [ $ skel [ 'constructorArgs' ] ] ; $ cons_args = [ ] ; foreach ( $ constructor_args as $ arg ) { $ val_array = static :: forceString ( $ arg ) ; array_push ( $ cons_args , $ val_array [ 0 ] ) ; if ( ! empty ( $ val_array [ 1 ] ) ) { $ import = array_merge ( $ import , $ val_array [ 1 ] ) ; } } if ( empty ( $ constructor_args [ 0 ] ) ) { $ cons_args = '' ; } else { $ cons_args = implode ( ',' , $ cons_args ) ; } return [ sprintf ( '%s(%s)' , $ class , $ cons_args ) , $ import , ] ; } if ( true === $ value ) { return [ 'true' , [ ] ] ; } if ( false === $ value ) { return [ 'false' , [ ] ] ; } if ( null === $ value ) { return [ 'null' , [ ] ] ; } return [ $ value , [ ] ] ; } | Converts a value to a string ready for writing on a file . |
36,425 | protected function abort ( $ message , $ error_code , InputInterface $ input , OutputInterface $ output ) { if ( $ input -> getOption ( 'json' ) ) { $ output -> writeln ( json_encode ( [ 'ok' => false , 'error_message' => $ message , 'error_code' => $ error_code , ] ) ) ; } else { $ output -> writeln ( $ message ) ; } return $ error_code < 1 ? 1 : $ error_code ; } | Abort due to error . |
36,426 | protected function success ( $ message , InputInterface $ input , OutputInterface $ output ) { if ( $ input -> getOption ( 'json' ) ) { $ output -> writeln ( json_encode ( [ 'ok' => true , 'message' => $ message , ] ) ) ; } else { $ output -> writeln ( $ message ) ; } return 0 ; } | Show success message . |
36,427 | protected function abortDueToException ( Exception $ e , InputInterface $ input , OutputInterface $ output ) { $ message = $ e -> getMessage ( ) ; $ code = $ this -> exceptionToErrorCode ( $ e ) ; if ( $ input -> getOption ( 'json' ) ) { $ response = [ 'ok' => false , 'error_message' => $ message , 'error_code' => $ code , ] ; if ( $ input -> getOption ( 'debug' ) ) { $ response [ 'error_class' ] = get_class ( $ e ) ; $ response [ 'error_file' ] = $ e -> getFile ( ) ; $ response [ 'error_line' ] = $ e -> getLine ( ) ; $ response [ 'error_trace' ] = $ e -> getTraceAsString ( ) ; } $ output -> writeln ( json_encode ( $ response ) ) ; } else { if ( $ input -> getOption ( 'debug' ) ) { $ output -> writeln ( 'Jobs error: <' . get_class ( $ e ) . '>' . $ message . ', in file ' . $ e -> getFile ( ) . ' on line ' . $ e -> getLine ( ) ) ; $ output -> writeln ( '' ) ; $ output -> writeln ( 'Backtrace' ) ; $ output -> writeln ( '' ) ; $ output -> writeln ( $ e -> getTraceAsString ( ) ) ; } else { $ output -> writeln ( 'Jobs error: ' . $ message ) ; } } return $ code ; } | Abort due to an exception . |
36,428 | protected function getDateTimeFromArgument ( InputInterface $ input , $ argument , $ default ) { $ value = $ input -> getArgument ( $ argument ) ; if ( empty ( $ value ) ) { $ value = $ default ; } return new DateTime ( $ value , new DateTimeZone ( 'GMT' ) ) ; } | Return a date time instance from input argument . |
36,429 | private function resolveOutputField ( ) { if ( is_null ( $ this -> outputField ) ) { $ sourceFields = $ this -> getSourceFields ( ) ; if ( 0 == count ( $ sourceFields ) ) { $ this -> outputField = null ; } else { foreach ( $ sourceFields as $ sourceField ) { if ( is_null ( $ this -> outputField ) ) { $ this -> outputField = $ sourceField ; } if ( ! is_null ( $ this -> outputField ) && ! ( $ this -> outputField instanceof $ sourceField ) ) { throw new FieldError ( 'Expression contains mixed types. You must set output_field' ) ; } } } } } | Attempts to infer the output type of the expression . If the output fields of all source fields match then we can simply infer the same type here . This isn t always correct but it makes sense most of the time . |
36,430 | public function getGroupByCols ( ) { if ( ! $ this -> containsAggregates ( ) ) { return [ $ this ] ; } $ cols = [ ] ; foreach ( $ this -> getSourceExpressions ( ) as $ sourceExpression ) { $ cols [ ] = $ sourceExpression -> getGroupByCols ( ) ; } return $ cols ; } | Retuns the fields to be used when this expression is used in a group by . |
36,431 | public function registerPermissions ( PluginPermissionsEvent $ event ) { $ event -> registerPermissions ( $ this -> translator -> trans ( 'plugin.ingest.permissions.label' ) , array ( 'plugin_ingest_settings' => $ this -> translator -> trans ( 'plugin.ingest.permissions.settings' ) ) ) ; } | Register plugin permissions in Newscoop ACL |
36,432 | static function optionsframework_tabs ( $ option_name , $ options ) { $ counter = 0 ; $ menu = '' ; foreach ( $ options as $ value ) { if ( $ value [ 'type' ] == "heading" ) { $ counter ++ ; $ class = '' ; $ class = ! empty ( $ value [ 'id' ] ) ? $ value [ 'id' ] : $ value [ 'name' ] ; $ class = preg_replace ( '/[^a-zA-Z0-9._\-]/' , '' , strtolower ( $ class ) ) . '-tab' ; $ menu .= '<a id="options-group-' . $ counter . '-tab" class="nav-tab ' . $ class . '" title="' . esc_attr ( $ value [ 'name' ] ) . '" href="' . esc_attr ( '#options-group-' . $ counter ) . '">' . esc_html ( $ value [ 'name' ] ) . '</a>' ; } } return $ menu ; } | Generates the tabs that are used in the options menu |
36,433 | private function getDirContent ( $ ext = 'php' , $ recurse = true , $ _fileObj = false ) { $ _fileList = [ ] ; $ ext = $ this -> stableExt ( $ ext ) ; $ directory = $ this -> stableDir ( $ this -> path ) ; if ( ! file_exists ( $ directory ) ) { return [ ] ; } $ dirIterator = new \ DirectoryIterator ( $ directory ) ; foreach ( $ dirIterator as $ file ) { if ( $ file -> isDot ( ) ) { continue ; } if ( $ file -> isDir ( ) && $ recurse ) { $ _fileList = array_merge ( $ _fileList , ( new static ( $ file -> getRealPath ( ) ) ) -> readDir ( $ ext , $ recurse ) ) ; } else { $ _fileList = $ this -> addFile ( $ _fileList , $ file , $ ext , $ _fileObj ) ; } } return $ _fileList ; } | Read contents inside a directory . |
36,434 | protected function groupedPaginate ( $ paginator , $ perPage , $ columns ) { $ results = $ this -> get ( $ columns ) ; return $ this -> buildRawPaginator ( $ paginator , $ results , $ perPage ) ; } | Create a paginator for a grouped pagination statement . |
36,435 | public function buildRawPaginator ( $ paginator , $ results , $ perPage ) { $ start = ( $ paginator -> getCurrentPage ( ) - 1 ) * $ perPage ; $ sliced = array_slice ( $ results , $ start , $ perPage ) ; return $ paginator -> make ( $ sliced , count ( $ results ) , $ perPage ) ; } | Build a paginator instance from a raw result array . |
36,436 | public function getPaginationCount ( ) { list ( $ orders , $ this -> orders ) = array ( $ this -> orders , null ) ; $ columns = $ this -> columns ; $ total = $ this -> count ( ) ; $ this -> orders = $ orders ; $ this -> columns = $ columns ; return $ total ; } | Get the count of the total records for pagination . |
36,437 | public static function filterCategoriesByParentSlug ( $ query , $ slug ) { $ obj = \ Delatbabel \ NestedCategories \ Models \ Category :: where ( 'slug' , $ slug ) -> first ( ) ; if ( $ obj ) { $ query -> where ( 'parent_id' , $ obj -> id ) ; } else { $ query -> where ( 'slug' , $ slug ) ; } } | Returns a query to find subcategories of a parent category by the slug . |
36,438 | public static function filterCategoriesByParentName ( $ query , $ name ) { $ obj = \ Delatbabel \ NestedCategories \ Models \ Category :: where ( 'name' , $ name ) -> whereNull ( 'parent_id' ) -> first ( ) ; if ( $ obj ) { $ query -> where ( 'parent_id' , $ obj -> id ) ; } else { $ query -> where ( 'name' , $ name ) ; } } | Returns a query to find subcategories of a parent category by the name . |
36,439 | protected function hasRule ( $ attribute , $ rules ) { $ rules = ( array ) $ rules ; foreach ( $ this -> rules [ $ attribute ] as $ rule ) { list ( $ rule , $ parameters ) = $ this -> parseRule ( $ rule ) ; if ( in_array ( $ rule , $ rules ) ) return true ; } return false ; } | Determine if the given attribute has a rule in the given set . |
36,440 | public function addExtensions ( array $ extensions ) { if ( $ extensions ) { $ keys = array_map ( 'snake_case' , array_keys ( $ extensions ) ) ; $ extensions = array_combine ( $ keys , array_values ( $ extensions ) ) ; } $ this -> extensions = array_merge ( $ this -> extensions , $ extensions ) ; } | Register an array of custom validator extensions . |
36,441 | public function addReplacers ( array $ replacers ) { if ( $ replacers ) { $ keys = array_map ( 'snake_case' , array_keys ( $ replacers ) ) ; $ replacers = array_combine ( $ keys , array_values ( $ replacers ) ) ; } $ this -> replacers = array_merge ( $ this -> replacers , $ replacers ) ; } | Register an array of custom validator message replacers . |
36,442 | protected function _execute ( array $ params ) { switch ( $ params [ 'manager' ] ) { case 'config' : $ config_path = APPPATH . 'config' . DIRECTORY_SEPARATOR . Kohana :: $ config -> load ( 'plugins.manager.Config.dir' ) ; if ( ! file_exists ( $ config_path ) ) { Minion_CLI :: write ( 'Creating plugin config folder' ) ; mkdir ( $ config_path ) ; $ config_tpl = "<?php defined('SYSPATH') OR die('No direct access allowed.');return array();" ; Minion_CLI :: write ( 'Creating plugin status & info config files' ) ; file_put_contents ( $ config_path . DIRECTORY_SEPARATOR . 'active.php' , $ config_tpl ) ; file_put_contents ( $ config_path . DIRECTORY_SEPARATOR . 'list.php' , $ config_tpl ) ; } break ; case 'db' : $ db = Database :: instance ( Kohana :: $ config -> load ( 'plugins.manager.DB.connection' ) ) ; Minion_CLI :: write ( 'Dumping SQL into database' ) ; $ db -> query ( null , "CREATE TABLE IF NOT EXISTS `" . Kohana :: $ config -> load ( 'plugins.manager.DB.table' ) . "` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(65) NOT NULL, `installed` tinyint(1) NOT NULL, `active` tinyint(1) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;" ) ; break ; } Minion_CLI :: write ( 'Installation ' . Minion_CLI :: color ( 'completed' , 'green' ) . 'for your ' . $ params [ 'manager' ] . ' manager' ) ; } | Truncate local database and import everything from the remote |
36,443 | public function requestAccess ( $ when , $ duration , $ visitors , $ phoneNumber ) { return $ this -> getSoapClient ( array_merge ( array ( $ when , $ duration , $ visitors , $ phoneNumber ) , array ( '__method' => 'requestAccess' ) ) ) -> requestAccess ( $ when , $ duration , $ visitors , $ phoneNumber ) ; } | Requests access to the data - center |
36,444 | public function requestRemoteHands ( $ coloName , $ contactName , $ phoneNumber , $ expectedDuration , $ instructions ) { return $ this -> getSoapClient ( array_merge ( array ( $ coloName , $ contactName , $ phoneNumber , $ expectedDuration , $ instructions ) , array ( '__method' => 'requestRemoteHands' ) ) ) -> requestRemoteHands ( $ coloName , $ contactName , $ phoneNumber , $ expectedDuration , $ instructions ) ; } | Request remote hands to the data - center |
36,445 | public function createIpAddress ( $ ipAddress , $ reverseDns ) { return $ this -> getSoapClient ( array_merge ( array ( $ ipAddress , $ reverseDns ) , array ( '__method' => 'createIpAddress' ) ) ) -> createIpAddress ( $ ipAddress , $ reverseDns ) ; } | Adds a new IpAddress either an ipv6 or an ipv4 address . The service will validate the address ensure the user is entitled to the address and will add the address to the correct Colo and range . |
36,446 | public function setReverseDns ( $ ipAddress , $ reverseDns ) { return $ this -> getSoapClient ( array_merge ( array ( $ ipAddress , $ reverseDns ) , array ( '__method' => 'setReverseDns' ) ) ) -> setReverseDns ( $ ipAddress , $ reverseDns ) ; } | Set the RDNS name for an ipAddress . Throws an Exception when the Address does not exist or is not owned by the user . |
36,447 | protected function getTemplate ( $ template , $ className ) { $ this -> template = $ this -> file -> get ( $ template ) ; $ models = strtolower ( str_replace ( 'TableSeeder' , '' , $ className ) ) ; $ this -> template = str_replace ( '{{className}}' , $ className , $ this -> template ) ; return str_replace ( '{{models}}' , $ models , $ this -> template ) ; } | Fetch the compiled template for a seed |
36,448 | public function updateDatabaseSeederRunMethod ( $ className ) { $ databaseSeederPath = app_path ( ) . '/database/seeds/DatabaseSeeder.php' ; $ content = $ this -> file -> get ( $ databaseSeederPath ) ; if ( ! strpos ( $ content , "\$this->call('{$className}');" ) ) { $ content = preg_replace ( "/(run\(\).+?)}/us" , "$1\t\$this->call('{$className}');\n\t}" , $ content ) ; return $ this -> file -> put ( $ databaseSeederPath , $ content ) ; } return false ; } | Updates the DatabaseSeeder file s run method to call this new seed class |
36,449 | public function store ( Listener $ listener , array $ input ) { $ input [ 'slug' ] = $ this -> generateUniqueSlug ( $ input ) ; $ validation = $ this -> validator -> on ( 'create' ) -> with ( $ input ) ; if ( $ validation -> fails ( ) ) { return $ listener -> storeHasFailedValidation ( $ validation -> getMessageBag ( ) ) ; } $ content = new Eloquent ( ) ; $ content -> setAttribute ( 'type' , $ input [ 'type' ] ) ; $ content -> setAttribute ( 'user_id' , $ this -> user -> id ) ; $ listener -> authorize ( 'create' , $ content ) ; $ this -> saving ( $ content , $ input ) ; return $ listener -> storeHasSucceed ( $ content , $ input ) ; } | Store new content . |
36,450 | public function destroy ( Listener $ listener , $ id ) { $ content = Eloquent :: findOrFail ( $ id ) ; $ listener -> authorize ( 'delete' , $ content ) ; $ content -> delete ( ) ; return $ listener -> deletionHasSucceed ( $ content ) ; } | Destroy a content . |
36,451 | protected function saving ( Eloquent $ content , array $ input ) { $ content -> setAttribute ( 'title' , $ input [ 'title' ] ) ; $ content -> setAttribute ( 'content' , $ input [ 'content' ] ) ; $ content -> setAttribute ( 'slug' , $ input [ 'slug' ] ) ; $ content -> setAttribute ( 'format' , $ input [ 'format' ] ) ; $ content -> setAttribute ( 'status' , $ input [ 'status' ] ) ; $ this -> updatePublishedAt ( $ content ) && $ content -> setAttribute ( 'published_at' , Carbon :: now ( ) ) ; $ content -> save ( ) ; } | Saving content . |
36,452 | protected function updatePublishedAt ( Eloquent $ content ) { $ start = new Carbon ( '0000-00-00 00:00:00' ) ; if ( $ content -> getAttribute ( 'status' ) !== Eloquent :: STATUS_PUBLISH ) { return false ; } $ published = $ content -> getAttribute ( 'published_at' ) ; switch ( true ) { case is_null ( $ published ) : case $ published -> format ( 'Y-m-d H:i:s' ) === '0000-00-00 00:00:00' : case $ published -> toDateTimeString ( ) === $ start -> toDateTimeString ( ) : return true ; default : return false ; } } | Determine whether published_at should be updated . |
36,453 | public function commands ( $ commands ) { $ commands = is_array ( $ commands ) ? $ commands : func_get_args ( ) ; $ events = $ this -> app [ 'events' ] ; $ events -> listen ( 'flyconsole.start' , function ( $ flyconsole ) use ( $ commands ) { $ flyconsole -> resolveCommands ( $ commands ) ; } ) ; } | Register the package s custom FlyConsole commands . |
36,454 | public function setBroker ( array $ options ) { $ namespace = self :: RHUBARB_BROKER_NAMESPACE ; if ( isset ( $ options [ 'class_namespace' ] ) && $ options [ 'class_namespace' ] ) { $ namespace = $ options [ 'class_namespace' ] ; } $ namespace = rtrim ( $ namespace , self :: NS_SEPERATOR ) ; $ brokerClass = $ namespace . self :: NS_SEPERATOR . $ options [ 'type' ] ; if ( ! class_exists ( $ brokerClass ) ) { throw new Exception ( sprintf ( 'Broker class [%s] unknown' , $ brokerClass ) ) ; } $ reflect = new \ ReflectionClass ( $ brokerClass ) ; $ this -> broker = $ reflect -> newInstanceArgs ( array ( ( array ) @ $ options [ 'options' ] ) ) ; return $ this ; } | Accepts an array of options enabling the declaration and instantiation of the broker object . |
36,455 | public function setResultStore ( array $ options ) { if ( ! isset ( $ options [ 'type' ] ) ) { return $ this ; } $ namespace = self :: RHUBARB_RESULTSTORE_NAMESPACE ; if ( isset ( $ options [ 'class_namespace' ] ) && $ options [ 'class_namespace' ] ) { $ namespace = $ options [ 'class_namespace' ] ; } $ namespace = rtrim ( $ namespace , self :: NS_SEPERATOR ) ; $ resultStoreClass = $ namespace . self :: NS_SEPERATOR . $ options [ 'type' ] ; if ( ! class_exists ( $ resultStoreClass ) ) { throw new Exception ( sprintf ( 'ResultStore class [%s] unknown' , $ resultStoreClass ) ) ; } $ reflect = new \ ReflectionClass ( $ resultStoreClass ) ; $ this -> resultBroker = $ reflect -> newInstanceArgs ( array ( ( array ) @ $ options [ 'options' ] ) ) ; return $ this ; } | Instantiates the ResultStore object by using user supplied options . Supported options are as follows ; |
36,456 | public function getOption ( $ name ) { $ name = strtolower ( $ name ) ; if ( array_key_exists ( $ name , $ this -> options ) ) { return $ this -> options [ $ name ] ; } return null ; } | Returns the name options key |
36,457 | public function setOption ( $ name , $ value ) { if ( ! is_string ( $ name ) ) { throw new Exception ( 'invalid options name' ) ; } $ name = strtolower ( $ name ) ; if ( $ name == 'result_store' ) { $ this -> options [ 'result_store' ] = $ value ; $ this -> setResultStore ( $ value ) ; } elseif ( $ name == 'broker' ) { $ this -> options [ 'broker' ] = $ value ; $ this -> setBroker ( $ value ) ; } return $ this ; } | Allows the implementer to specify a single top level option at runtime . |
36,458 | public function cancel ( string $ id , bool $ atPeriodEnd ) { $ this -> flow -> getLogger ( ) -> debug ( "Cancelling Subscription $id" . ( $ atPeriodEnd ? ' at period end.' : '.' ) ) ; return $ this -> make ( $ this -> flow -> send ( 'post' , $ this -> endpoint . '/cancel' , [ 'subscriptionId' => $ id , 'at_period_end' => ( int ) $ atPeriodEnd , ] ) ) ; } | Cancels a Subscription |
36,459 | public function addCoupon ( string $ subscriptionId , string $ couponId ) { $ this -> flow -> getLogger ( ) -> debug ( "Adding Coupon $couponId to $subscriptionId" ) ; return $ this -> make ( $ this -> flow -> send ( 'post' , $ this -> endpoint . '/addCoupon' , [ 'subscriptionId' => $ subscriptionId , 'couponId' => $ couponId , ] ) ) ; } | Adds a Coupon to a Subscription |
36,460 | public function removeCoupon ( string $ subscriptionId ) { $ this -> flow -> getLogger ( ) -> debug ( "Removing Coupons from $subscriptionId" ) ; return $ this -> make ( $ this -> flow -> send ( 'post' , $ this -> endpoint . '/deleteCoupon' , [ 'subscriptionId' => $ subscriptionId ] ) ) ; } | Removes a Coupon from the Subscription |
36,461 | public static function getSetting ( $ scope , $ key ) { if ( ! count ( self :: $ settings ) ) { self :: load ( ) ; } if ( isset ( self :: $ settings [ $ scope ] [ $ key ] ) ) { return self :: $ settings [ $ scope ] [ $ key ] ; } return null ; } | Retrieve a setting |
36,462 | public static function set ( $ scope , $ key , $ value ) { $ settingStore = Store :: get ( 'Setting' ) ; $ setting = $ settingStore -> getByScopeKey ( $ scope , $ key ) ; $ setting -> setValue ( $ value ) ; $ settingStore -> save ( $ setting ) ; self :: load ( ) ; } | Update a setting |
36,463 | public function delete ( $ value ) { $ key = array_search ( $ value , $ this -> getArrayCopy ( ) , true ) ; if ( $ key !== false ) { unset ( $ this [ $ key ] ) ; return true ; } return false ; } | Removes the element associated to the value . |
36,464 | public function diff ( \ PhpSets \ Set $ set ) { $ entries = $ this -> entries ( ) ; $ iterator = $ set -> entries ( ) ; $ intersect = new \ PhpSets \ Set ; while ( $ entries -> valid ( ) ) { if ( ! $ set -> has ( $ entries -> current ( ) ) ) { $ intersect -> add ( $ entries -> current ( ) ) ; } $ entries -> next ( ) ; } while ( $ iterator -> valid ( ) ) { if ( ! $ this -> has ( $ iterator -> current ( ) ) ) { $ intersect -> add ( $ iterator -> current ( ) ) ; } $ iterator -> next ( ) ; } return $ intersect ; } | Returns a new Set containing all uncommon items between this and a given Set instance . |
36,465 | public function intersect ( \ PhpSets \ Set $ set ) { $ iterator = $ set -> entries ( ) ; $ intersect = new \ PhpSets \ Set ; while ( $ iterator -> valid ( ) ) { if ( $ this -> has ( $ iterator -> current ( ) ) ) { $ intersect -> add ( $ iterator -> current ( ) ) ; } $ iterator -> next ( ) ; } $ iterator -> rewind ( ) ; return $ intersect ; } | Returns a new Set object containing the common elements between two given sets |
36,466 | public function merge ( \ PhpSets \ Set $ set ) { $ iterator = $ set -> entries ( ) ; $ merged = new \ PhpSets \ Set ( ) ; $ merged -> exchangeArray ( $ this -> values ( ) ) ; while ( $ iterator -> valid ( ) ) { if ( ! $ this -> has ( $ iterator -> current ( ) ) ) { $ merged -> add ( $ iterator -> current ( ) ) ; } $ iterator -> next ( ) ; } $ iterator -> rewind ( ) ; return $ merged ; } | Returns a new Set which contains the unique items of the current and a given Set . |
36,467 | public function offsetSet ( $ offset , $ value ) { $ temp = $ this -> values ( ) ; if ( $ this -> has ( $ value ) === false ) { if ( is_null ( $ offset ) ) { $ temp [ ] = $ value ; } else { $ temp [ $ offset ] = $ value ; } } $ this -> exchangeArray ( $ temp ) ; $ this -> size = $ this -> count ( ) ; } | The main setter for the Array functionality . |
36,468 | public function offsetUnset ( $ offset ) { $ temp = $ this -> values ( ) ; if ( isset ( $ temp [ $ offset ] ) ) { unset ( $ temp [ $ offset ] ) ; } $ this -> exchangeArray ( array_values ( $ temp ) ) ; $ this -> size = $ this -> count ( ) ; } | The main UNsetter for the Array functionality . |
36,469 | public function getAncestors ( $ ignoreSelf = false ) { $ ancestors = [ ] ; if ( false === $ ignoreSelf ) { $ ancestors [ $ this -> name ] = $ this -> appName ; } foreach ( $ this -> parent as $ parent ) { $ parentAncenstors = $ parent -> getAncestors ( ) ; $ ancestors = array_merge ( $ parentAncenstors , $ ancestors ) ; } return $ ancestors ; } | Get ancestors from the first ancestor aka adam and eve to upto this node . that is oldest at index 0 . |
36,470 | public function getDescendants ( ) { $ descendants = [ ] ; $ descendants [ $ this -> name ] = $ this -> appName ; foreach ( $ this -> children as $ child ) { $ childDescendats = $ child -> getDescendants ( ) ; $ descendants = array_merge ( $ childDescendats , $ descendants ) ; } return $ descendants ; } | Get all nodes the consider this node there first ancestor including this one . This puts the last child as the first element on returned array while this node becomes the last . |
36,471 | protected function _checkAccess ( array $ url , array $ user ) : bool { $ accessFactory = new AccessFactory ( ) ; return $ accessFactory -> hasAccess ( $ url , $ user ) ; } | Check if current user has access to perform action . |
36,472 | protected function checkValue ( & $ errors = [ ] ) { if ( $ this -> getRequired ( ) && ! array_key_exists ( $ this -> getName ( ) , $ _FILES ) ) { $ errors [ ] = $ this -> getLabel ( ) . ' is required.' ; $ this -> error = $ this -> getLabel ( ) . ' is required.' ; return false ; } return true ; } | Check whether the correct value has been entered |
36,473 | protected function getChannels ( $ channels ) { $ channels = trim ( $ channels ) ; if ( empty ( $ channels ) ) { throw new InvalidArgumentException ( 'No channel found.' ) ; } return $ channels === '*' ? [ ] : explode ( ',' , $ channels ) ; } | Convert channels string to channel list . |
36,474 | public function fields ( $ fields , $ path = null ) { if ( is_null ( $ fields ) ) return ; $ path = $ path ? : __DIR__ . '/../tmp-fields.txt' ; $ fields = preg_split ( '/, ?/' , $ fields ) ; $ arrayFields = array ( ) ; foreach ( $ fields as $ pair ) { list ( $ key , $ val ) = preg_split ( '/ ?: ?/' , $ pair ) ; $ arrayFields [ $ key ] = $ val ; } return $ this -> file -> put ( $ path , json_encode ( $ arrayFields ) ) ; } | Save fields to cached file for future use by other commands |
36,475 | public function getFields ( $ path = null ) { $ path = $ path ? : __DIR__ . '/../tmp-fields.txt' ; if ( ! is_null ( $ this -> fields ) ) { return $ this -> fields ; } if ( file_exists ( $ path ) ) { return $ this -> fields = json_decode ( $ this -> file -> get ( $ path ) , true ) ; } $ this -> fields = false ; return false ; } | Fetches the cached fields for the resource |
36,476 | public function modelName ( $ modelName , $ path = null ) { $ path = $ path ? : __DIR__ . '/../tmp-model.txt' ; return $ this -> file -> put ( $ path , $ modelName ) ; } | Cache the model name |
36,477 | public function getModelName ( $ path = null ) { $ path = $ path ? : __DIR__ . '/../tmp-model.txt' ; if ( ! is_null ( $ this -> model ) ) { return $ this -> model ; } if ( file_exists ( $ path ) ) { return $ this -> model = $ this -> file -> get ( $ path ) ; } } | Fetch the model name |
36,478 | public static function loadRDF ( $ url , $ uri = null , $ format = null ) { try { $ rdf = \ EasyRdf_Graph :: newAndLoad ( $ url , $ format ) ; return $ rdf -> resource ( $ uri ? $ uri : $ url ) ; } catch ( \ Exception $ e ) { return ; } } | Silently try to load RDF from an URL . |
36,479 | public static function getURIs ( \ EasyRDF_Resource $ subject , $ predicate , $ pattern = null ) { $ uris = [ ] ; foreach ( $ subject -> allResources ( $ predicate ) as $ object ) { if ( ! $ object -> isBNode ( ) ) { $ object = $ object -> getUri ( ) ; if ( ! $ pattern or preg_match ( $ pattern , $ object ) ) { $ uris [ ] = $ object ; } } } return $ uris ; } | Get a list of RDF object URIs . |
36,480 | protected function getPaginationPrevLink ( $ page , $ uri ) { $ rtn = '' ; if ( $ page != 1 ) { $ cls = ( $ page == 1 ? 'disabled' : '' ) ; $ rtn .= '<li class="' . $ cls . '"><a href="' . $ uri . '">«</a></li>' ; $ rtn .= '<li class="' . $ cls . '"><a href="' . $ uri . 'p=' . ( $ page - 1 ) . '">« Prev</a></li>' ; } return $ rtn ; } | Setup pagination previous link |
36,481 | protected function getPaginationNextLink ( $ page , $ uri , $ pages ) { $ rtn = '' ; if ( $ page != $ pages ) { $ cls = ( $ page == $ pages ? 'disabled' : '' ) ; $ rtn .= '<li class="' . $ cls . '"><a href="' . $ uri . 'p=' . ( $ page + 1 ) . '">Next »</a></li>' ; $ rtn .= '<li class="' . $ cls . '"><a href="' . $ uri . 'p=' . $ pages . '">»</a></li>' ; } return $ rtn ; } | Setup pagination next link |
36,482 | protected function runCreator ( $ package ) { $ path = $ this -> flyphp [ 'path.base' ] . '/workbench' ; $ plain = ! $ this -> option ( 'resources' ) ; return $ this -> creator -> create ( $ package , $ path , $ plain ) ; } | Run the package creator class for a given Package . |
36,483 | protected function buildPackage ( ) { list ( $ vendor , $ name ) = $ this -> getPackageSegments ( ) ; $ config = $ this -> flyphp [ 'config' ] [ 'workbench' ] ; return new Package ( $ vendor , $ name , $ config [ 'name' ] , $ config [ 'email' ] ) ; } | Build the package details from user input . |
36,484 | public function show ( ) { $ params = static :: $ router -> current ( ) -> parameters ( ) ; $ id = Arr :: get ( $ params , 'id' ) ; $ slug = Arr :: get ( $ params , 'slug' ) ; $ page = $ this -> getRequestedContent ( $ id , $ slug ) ; $ id = $ page -> getAttribute ( 'id' ) ; $ slug = $ page -> getAttribute ( 'slug' ) ; set_meta ( 'title' , $ page -> getAttribute ( 'title' ) ) ; return $ this -> getResponse ( $ page , $ id , $ slug ) ; } | Show the content . |
36,485 | static function section_name ( $ object ) { $ class_file = $ object -> class_file ( ) ; $ name = preg_replace ( '!^.+/bors-site/classes/' . $ object -> get ( 'project_name' ) . '(/admin)?/(\w+)/.+$!' , '$2' , $ class_file ) ; if ( ! preg_match ( '/^\w+$/' , $ name ) ) { $ name = blib_grammar :: plural ( preg_replace ( '!^.+/bors-site/classes/' . $ object -> get ( 'project_name' ) . '(/admin)?/(\w+)\.\w+.+$!' , '$2' , $ class_file ) ) ; } if ( ! preg_match ( '/^\w+$/' , $ name ) ) $ name = NULL ; return $ name ; } | ucrm_company_type = > company |
36,486 | public function getModelFiles ( ) { $ files = [ ] ; foreach ( $ this -> getOrm ( ) -> getComponents ( ) as $ component ) { if ( $ component instanceof AppInterface ) { $ fileHandler = new FileHandler ( $ component -> getModelsPath ( ) ) ; $ files [ $ component -> getName ( ) ] = $ fileHandler -> readDir ( 'php' ) ; } } return $ files ; } | Returns a list of all model files . |
36,487 | public function getModels ( $ includeAutoCreated = false , $ app = null ) : array { $ this -> isAppReady ( ) ; if ( $ includeAutoCreated && is_null ( $ app ) ) { return $ this -> allModels ; } if ( ! is_null ( $ app ) ) { $ appModels = $ this -> appModels [ $ app ] ; if ( ! $ includeAutoCreated ) { $ rModels = [ ] ; foreach ( $ appModels as $ name => $ appModel ) { if ( ! $ appModel -> getMeta ( ) -> autoCreated ) { $ rModels [ $ name ] = $ appModel ; } } $ appModels = $ rModels ; } return $ appModels ; } $ rModels = [ ] ; foreach ( $ this -> allModels as $ name => $ model ) { if ( ! $ includeAutoCreated && $ model -> getMeta ( ) -> autoCreated ) { continue ; } $ rModels [ $ name ] = $ model ; } return $ rModels ; } | Returns the list of all the models that extend the PModel in the current app . |
36,488 | protected function hydrateRegistry ( ) { if ( $ this -> ready ) { return ; } $ modelClasses = $ this -> getModelClasses ( ) ; $ callback = function ( \ ReflectionClass $ reflect ) use ( & $ callback , & $ classList ) { $ parentClass = $ reflect -> getParentClass ( ) -> getName ( ) ; if ( Model :: class === $ parentClass ) { $ extends = [ ] ; } else { if ( $ reflect -> getParentClass ( ) -> isAbstract ( ) ) { $ extends = $ callback ( $ reflect -> getParentClass ( ) ) ; } else { $ extends = [ $ parentClass ] ; } } $ classList = array_merge ( $ classList , $ extends ) ; return $ extends ; } ; if ( ! empty ( $ modelClasses ) ) { $ classPopulationOrder = [ ] ; $ classToAppMap = [ ] ; $ classList = [ ] ; foreach ( $ modelClasses as $ appName => $ classes ) { foreach ( $ classes as $ class ) { $ classToAppMap [ $ class ] = $ appName ; $ reflect = new \ ReflectionClass ( $ class ) ; if ( ! $ reflect -> isInstantiable ( ) ) { continue ; } if ( $ this -> hasModel ( $ class ) || ! $ reflect -> isSubclassOf ( Model :: class ) ) { continue ; } $ classList [ ] = $ reflect -> getName ( ) ; $ classPopulationOrder [ $ class ] = $ callback ( $ reflect ) ; } } $ classList = array_unique ( $ classList ) ; foreach ( $ classList as $ class ) { if ( ! ArrayHelper :: hasKey ( $ classToAppMap , $ class ) ) { throw new OrmException ( "Make '$class' abstract or register it as " . 'an application model' ) ; } } try { $ classPopulationOrder = Tools :: topologicalSort ( $ classPopulationOrder ) ; } catch ( CircularDependencyError $ e ) { throw new OrmException ( $ e -> getMessage ( ) ) ; } foreach ( $ classPopulationOrder as $ class ) { $ obj = new $ class ( [ 'registry' => $ this ] ) ; $ obj -> setupClassInfo ( null , [ 'meta' => [ 'appName' => $ classToAppMap [ $ class ] ] , 'registry' => $ this ] ) ; } } } | Loads all the models in the current application . |
36,489 | public function getModelClasses ( ) { $ models = [ ] ; $ modelFiles = $ this -> getModelFiles ( ) ; if ( empty ( $ modelFiles ) ) { return false ; } foreach ( $ this -> getModelFiles ( ) as $ appName => $ files ) { foreach ( $ files as $ file ) { $ className = ClassHelper :: getClassFromFile ( $ file ) ; if ( ! class_exists ( $ className ) ) { throw new ClassNotFoundException ( sprintf ( 'The class [ %s ] could not be located' , $ className ) ) ; } $ models [ $ appName ] [ ] = $ className ; } } return $ models ; } | Returns a list of all model names in lowercase or false if not models were found . |
36,490 | public function getRegisteredModel ( $ modelName ) { try { $ model = ArrayHelper :: getValue ( $ this -> allModels , $ modelName ) ; } catch ( KeyError $ e ) { $ model = null ; } if ( null == $ model ) { throw new LookupError ( sprintf ( "Models '%s' not registered." , $ modelName ) ) ; } return $ model ; } | Gets a registered model . This method is used internally to get a registered model without the possibility of side effects incase it not registerd . |
36,491 | protected function before ( $ instance , $ route , $ request , $ method ) { foreach ( $ instance -> getBeforeFilters ( ) as $ filter ) { if ( $ this -> filterApplies ( $ filter , $ request , $ method ) ) { $ response = $ this -> callFilter ( $ filter , $ route , $ request ) ; if ( ! is_null ( $ response ) ) return $ response ; } } } | Call the before filters for the controller . |
36,492 | protected function assignAfter ( $ instance , $ route , $ request , $ method ) { foreach ( $ instance -> getAfterFilters ( ) as $ filter ) { if ( $ this -> filterApplies ( $ filter , $ request , $ method ) ) { $ route -> after ( $ this -> getAssignableAfter ( $ filter ) ) ; } } } | Apply the applicable after filters to the route . |
36,493 | protected function filterFailsOnly ( $ filter , $ request , $ method ) { if ( ! isset ( $ filter [ 'options' ] [ 'only' ] ) ) return false ; return ! in_array ( $ method , ( array ) $ filter [ 'options' ] [ 'only' ] ) ; } | Determine if the filter fails the only cosntraint . |
36,494 | protected function filterFailsExcept ( $ filter , $ request , $ method ) { if ( ! isset ( $ filter [ 'options' ] [ 'except' ] ) ) return false ; return in_array ( $ method , ( array ) $ filter [ 'options' ] [ 'except' ] ) ; } | Determine if the filter fails the except cosntraint . |
36,495 | protected function createDatabaseProvider ( ) { $ connection = $ this -> app [ 'db' ] -> connection ( ) ; $ table = $ this -> app [ 'config' ] [ 'auth.table' ] ; return new DatabaseUserProvider ( $ connection , $ this -> app [ 'hash' ] , $ table ) ; } | Create an instance of the database user provider . |
36,496 | protected function getTemplate ( $ template , $ className ) { $ this -> template = $ this -> file -> get ( $ template ) ; if ( $ this -> needsScaffolding ( $ template ) ) { $ this -> template = $ this -> getScaffoldedModel ( $ className ) ; } return str_replace ( '{{className}}' , $ className , $ this -> template ) ; } | Fetch the compiled template for a model |
36,497 | static private function diff ( $ a , $ b ) { $ a_code = explode ( "\n" , file_get_contents ( $ a ) ) ; $ b_code = explode ( "\n" , file_get_contents ( $ b ) ) ; $ diff = new \ Diff ( $ b_code , $ a_code , array ( 'ignoreWhitespace' => TRUE , 'ignoreNewLines' => TRUE ) ) ; return $ diff -> render ( new \ Diff_Renderer_Text_Unified ( ) ) ; } | Get the difference between two files |
36,498 | public function install ( InstalledRepositoryInterface $ repo , PackageInterface $ package ) { parent :: install ( $ repo , $ package ) ; if ( getenv ( 'OPUS_DISABLED' ) ) { return ; } if ( ! $ this -> checkFrameworkSupport ( $ package ) ) { return ; } $ this -> loadInstallationMap ( ) ; $ this -> copyMap ( $ this -> buildPackageMap ( $ package ) , $ result ) ; $ this -> resolve ( $ result ) ; $ this -> saveInstallationMap ( $ result ) ; $ this -> io -> write ( PHP_EOL ) ; } | Installs a package |
36,499 | public function uninstall ( InstalledRepositoryInterface $ repo , PackageInterface $ package ) { if ( getenv ( 'OPUS_DISABLED' ) ) { parent :: uninstall ( $ repo , $ package ) ; return ; } if ( ! $ this -> checkFrameworkSupport ( $ package ) ) { return ; } $ this -> loadInstallationMap ( ) ; foreach ( $ this -> installationMap as $ path => $ packages ) { if ( ( $ key = array_search ( $ package -> getName ( ) , $ packages ) ) !== FALSE ) { unset ( $ this -> installationMap [ $ path ] [ $ key ] ) ; } } $ this -> cleanup ( ) ; $ this -> saveInstallationMap ( ) ; parent :: uninstall ( $ repo , $ package ) ; } | Uninstalls a package |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.