idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
1,300
public static function coming_events ( $ from = false ) { $ time = ( $ from ? strtotime ( $ from ) : mktime ( 0 , 0 , 0 , date ( 'm' ) , date ( 'd' ) , date ( 'Y' ) ) ) ; $ sql = "(StartDateTime >= '" . date ( 'Y-m-d' , $ time ) . " 00:00:00')" ; $ events = PublicEvent :: get ( ) -> where ( $ sql ) ; return $ events ; }
Get all coming public events
1,301
public static function coming_events_limited ( $ from = false , $ limit = 30 ) { $ events = self :: coming_events ( $ from ) -> limit ( $ limit ) ; return $ events ; }
Get all coming public events - with optional limit
1,302
public static function add_preview_params ( $ link , $ object ) { if ( ! Member :: currentUserID ( ) ) { return $ link ; } $ modifiedLink = '' ; $ request = Controller :: curr ( ) -> getRequest ( ) ; if ( $ request && $ request -> getVar ( 'CMSPreview' ) ) { $ modifiedLink = HTTP :: setGetVar ( 'CMSPreview' , 1 , $ link ) ; $ modifiedLink = str_replace ( '&' , '&' , $ modifiedLink ) ; if ( ! empty ( $ object -> SubsiteID ) ) { $ modifiedLink = HTTP :: setGetVar ( 'SubsiteID' , $ object -> SubsiteID , $ modifiedLink ) ; $ modifiedLink = str_replace ( '&' , '&' , $ modifiedLink ) ; } } return ( $ modifiedLink ) ? $ modifiedLink : $ link ; }
If applicable adds preview parameters . ie . CMSPreview and SubsiteID .
1,303
protected function assemble ( ) { $ assembled = $ this -> command ; foreach ( $ this -> arguments as $ key => $ value ) { if ( is_int ( $ key ) && false === strpos ( ( string ) $ key , '-' ) ) { $ assembled .= ' ' . escapeshellarg ( $ value ) ; continue ; } $ assembled .= ' ' . escapeshellarg ( $ key ) ; $ assembled .= ' ' . escapeshellarg ( $ value ) ; } return $ assembled ; }
Assemble command and arguments .
1,304
public static function createEmbeddedShell ( SessionInterface $ session ) { $ container = new Container ( self :: MODE_EMBEDDED_SHELL ) ; $ container -> get ( 'phpcr.session_manager' ) -> setSession ( new PhpcrSession ( $ session ) ) ; $ application = $ container -> get ( 'application' ) ; return new Shell ( $ application ) ; }
Create a new embedded shell .
1,305
private function replaceColumnOperands ( $ functionMap , RowInterface $ row ) { foreach ( $ this -> arguments as $ key => $ value ) { if ( $ value instanceof ColumnOperand ) { $ this -> arguments [ $ key ] = $ row -> getNode ( $ value -> getSelectorName ( ) ) -> getPropertyValue ( $ value -> getPropertyName ( ) ) ; } if ( $ value instanceof self ) { $ this -> arguments [ $ key ] = $ value -> execute ( $ functionMap , $ row , $ value ) ; } } }
Replace the Operand objects with their evaluations .
1,306
public function execute ( $ functionMap , $ row ) { $ this -> replaceColumnOperands ( $ functionMap , $ row ) ; $ functionName = $ this -> getFunctionName ( ) ; if ( ! isset ( $ functionMap [ $ functionName ] ) ) { throw new InvalidQueryException ( sprintf ( 'Unknown function "%s", known functions are "%s"' , $ functionName , implode ( ', ' , array_keys ( $ functionMap ) ) ) ) ; } $ callable = $ functionMap [ $ functionName ] ; $ args = $ this -> getArguments ( ) ; array_unshift ( $ args , $ row ) ; array_unshift ( $ args , $ this ) ; $ value = call_user_func_array ( $ callable , $ args ) ; return $ value ; }
Evaluate the result of the function .
1,307
public function validateScalarArray ( $ array ) { if ( ! is_array ( $ array ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Expected array value, got: %s' , var_export ( $ array , true ) ) ) ; } foreach ( $ array as $ key => $ value ) { if ( false == is_scalar ( $ value ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Cannot use an array as a value in a multivalue property. Value was: %s' , var_export ( $ array , true ) ) ) ; } } }
Used as callback for closure functions .
1,308
public function register ( $ name , Closure $ callback ) { $ this -> checkCallbackName ( $ name ) ; $ this -> callbacks [ $ name ] = $ callback ; return $ this ; }
Register a breadcrumb domain .
1,309
public function render ( $ name = null , ... $ params ) { return new HtmlString ( view ( $ this -> getView ( ) , [ 'breadcrumbs' => $ this -> generate ( $ name , $ params ) ] ) -> render ( ) ) ; }
Render breadcrumbs items .
1,310
public function generate ( $ name , ... $ params ) { return ( new Builder ( $ this -> callbacks ) ) -> call ( $ name , $ params ) -> toArray ( ) ; }
Generate the breadcrumbs .
1,311
private function checkTemplate ( $ template ) { if ( ! is_string ( $ template ) ) { $ type = gettype ( $ template ) ; throw new Exceptions \ InvalidTypeException ( "The default template name must be a string, $type given." ) ; } $ template = strtolower ( trim ( $ template ) ) ; if ( ! array_key_exists ( $ template , $ this -> supported ) ) { throw new Exceptions \ InvalidTemplateException ( "The template [$template] is not supported." ) ; } }
Check Template .
1,312
public function calendarview ( ) { $ s = CalendarConfig :: subpackage_settings ( 'pagetypes' ) ; if ( isset ( $ s [ 'calendarpage' ] [ 'calendarview' ] ) && $ s [ 'calendarpage' ] [ 'calendarview' ] ) { Requirements :: javascript ( 'calendar/thirdparty/fullcalendar/2.9.1/fullcalendar/lib/moment.min.js' ) ; Requirements :: javascript ( 'calendar/thirdparty/fullcalendar/2.9.1/fullcalendar/fullcalendar.min.js' ) ; Requirements :: css ( 'calendar/thirdparty/fullcalendar/2.9.1/fullcalendar/fullcalendar.min.css' ) ; Requirements :: css ( 'calendar/thirdparty/fullcalendar/2.9.1/fullcalendar/fullcalendar.print.css' , 'print' ) ; Requirements :: javascript ( 'calendar/thirdparty/xdate/xdate.js' ) ; Requirements :: javascript ( 'calendar/javascript/fullcalendar/PublicFullcalendarView.js' ) ; $ url = CalendarHelper :: add_preview_params ( $ this -> Link ( ) , $ this -> data ( ) ) ; $ fullcalendarjs = $ s [ 'calendarpage' ] [ 'fullcalendar_js_settings' ] ; $ controllerUrl = CalendarHelper :: add_preview_params ( $ s [ 'calendarpage' ] [ 'controllerUrl' ] , $ this -> data ( ) ) ; $ shadedEvents = 'false' ; $ sC = CalendarConfig :: subpackage_settings ( 'calendars' ) ; if ( $ sC [ 'shading' ] ) { $ shadedEvents = 'true' ; } Requirements :: customScript ( " (function($) { $(function () { //Initializing fullcalendar var cal = new PublicFullcalendarView($('#calendar'), '$url', { controllerUrl: '$controllerUrl', fullcalendar: { $fullcalendarjs }, shadedevents: $shadedEvents }); }); })(jQuery); " ) ; return $ this ; } else { return $ this -> httpError ( 404 ) ; } }
Calendar View Renders the fullcalendar
1,313
public function detail ( $ req ) { $ event = Event :: get ( ) -> byID ( $ req -> param ( 'ID' ) ) ; if ( ! $ event ) { return $ this -> httpError ( 404 ) ; } return array ( 'Event' => $ event , ) ; }
Displays details of an event
1,314
public function Events ( ) { $ action = $ this -> request -> param ( 'Action' ) ; $ s = CalendarConfig :: subpackage_settings ( 'pagetypes' ) ; $ indexSetting = $ s [ 'calendarpage' ] [ 'index' ] ; if ( $ action == 'eventregistration' || $ action == 'eventlist' || ( $ action == '' && $ indexSetting == 'eventlist' ) ) { $ events = CalendarHelper :: events_for_month ( $ this -> CurrentMonth ( ) ) ; if ( $ action == 'eventregistration' ) { $ events = $ events -> filter ( 'Registerable' , 1 ) ; } return $ events ; } if ( $ action == 'search' ) { $ query = $ this -> SearchQuery ( ) ; $ query = strtolower ( addslashes ( $ query ) ) ; $ qarr = preg_split ( '/[ +]/' , $ query ) ; $ filter = '' ; $ first = true ; foreach ( $ qarr as $ qitem ) { if ( ! $ first ) { $ filter .= " AND " ; } $ filter .= " ( Title LIKE '%$qitem%' OR Details LIKE '%$qitem%' )" ; $ first = false ; } $ events = CalendarHelper :: all_events ( ) -> where ( $ filter ) ; return $ events ; } }
Event list for eventlist mode
1,315
public function CurrentCalendar ( ) { $ url = Convert :: raw2url ( $ this -> request -> param ( 'ID' ) ) ; $ cal = PublicCalendar :: get ( ) -> filter ( 'URLSegment' , $ url ) -> First ( ) ; return $ cal ; }
Renders the current calendar if a calenar link has been supplied via the url
1,316
public function hasDescriptor ( $ descriptor , $ value = null ) { $ this -> loadDescriptors ( ) ; $ exists = array_key_exists ( $ descriptor , $ this -> descriptors ) ; if ( false === $ exists ) { return false ; } if ( null === $ value ) { return true ; } $ descriptorValue = $ this -> descriptors [ $ descriptor ] ; if ( $ descriptorValue === 'true' ) { $ descriptorValue = true ; } if ( $ descriptorValue === 'false' ) { $ descriptorValue = false ; } if ( $ value === $ descriptorValue ) { return true ; } return false ; }
Return true if the sessionManager supports the given descriptor which relates to a descriptor key .
1,317
public function getMedia ( $ id = 'self' , $ count = null , $ minId = null , $ maxId = null ) { $ params = [ 'query' => [ 'count' => $ count , 'min_id' => $ minId , 'max_id' => $ maxId , ] ] ; return $ this -> client -> request ( 'GET' , "users/$id/media/recent" , $ params ) ; }
Get the most recent media published by a user .
1,318
public function getLikedMedia ( $ count = null , $ maxLikeId = null ) { $ params = [ 'query' => [ 'count' => $ count , 'max_like_id' => $ maxLikeId ] ] ; return $ this -> client -> request ( 'GET' , 'users/self/media/liked' , $ params ) ; }
Get the list of recent media liked by the owner of the access token .
1,319
public function search ( $ query , $ count = null ) { $ params = [ 'query' => [ 'q' => $ query , 'count' => $ count , ] ] ; return $ this -> client -> request ( 'GET' , 'users/search' , $ params ) ; }
Get a list of users matching the query .
1,320
public function find ( $ username ) { $ response = $ this -> search ( $ username ) ; foreach ( $ response -> get ( ) as $ user ) { if ( $ username === $ user [ 'username' ] ) { return $ this -> get ( $ user [ 'id' ] ) ; } } return null ; }
Searches for and returns a single user s information . If no results are found null is returned .
1,321
protected function bindDefaultTriggers ( ) { $ this -> handlers [ self :: EVENT_INIT ] = $ this -> fluentCallback ( [ $ this , 'handleInit' ] ) ; $ this -> handlers [ self :: EVENT_FORK ] = $ this -> fluentCallback ( [ $ this , 'handleFork' ] ) ; $ this -> handlers [ self :: EVENT_START ] = $ this -> fluentCallback ( [ $ this , 'handleStart' ] ) ; }
Binds some callbacks as default triggers .
1,322
public function handleInit ( Control $ control , Context $ context ) { if ( ! $ context -> pidfile instanceof Pidfile ) { $ context -> pidfile = new Pidfile ( $ control , $ this -> getOption ( 'name' ) , $ this -> getOption ( 'lock_dir' ) ) ; } $ context -> isRunning = $ context -> pidfile -> isActive ( ) ; $ context -> processId = $ context -> pidfile -> getProcessId ( ) ; }
Default trigger for EVENT_INIT .
1,323
public function handleStart ( Control $ control , Context $ context ) { if ( ! $ context -> pidfile instanceof Pidfile ) { throw new LogicException ( 'Pidfile is not defined' ) ; } gc_enable ( ) ; $ control -> signal ( ) -> prependHandler ( SIGTERM , function ( ) use ( $ context ) { $ this -> setAsDying ( ) ; $ context -> pidfile -> finalize ( ) ; } ) ; $ control -> signal ( ) -> setHandler ( SIGTSTP , SIG_IGN ) ; $ control -> signal ( ) -> setHandler ( SIGTTOU , SIG_IGN ) ; $ control -> signal ( ) -> setHandler ( SIGTTIN , SIG_IGN ) ; $ control -> signal ( ) -> setHandler ( SIGHUP , SIG_IGN ) ; $ control -> info ( ) -> detachSession ( ) ; @ umask ( $ this -> getOption ( 'umask' ) ) ; @ chdir ( $ this -> getOption ( 'work_dir' ) ) ; fclose ( STDIN ) ; fclose ( STDOUT ) ; fclose ( STDERR ) ; if ( null !== ( $ userId = $ this -> getOption ( 'user_id' ) ) ) { $ control -> info ( ) -> setUserId ( $ userId ) ; } if ( null !== ( $ groupId = $ this -> getOption ( 'group_id' ) ) ) { $ control -> info ( ) -> setGroupId ( $ groupId ) ; } $ context -> stdin = fopen ( $ this -> getOption ( 'stdin' ) , 'r' ) ; $ context -> stdout = fopen ( $ this -> getOption ( 'stdout' ) , 'wb' ) ; $ context -> stderr = fopen ( $ this -> getOption ( 'stderr' ) , 'wb' ) ; $ context -> pidfile -> initialize ( ) ; }
Default trigger for EVENT_START .
1,324
public function onBlock ( BlockEvent $ event ) { $ identifier = $ event -> getSetting ( 'id' , null ) ; if ( null === $ identifier ) { return ; } $ block = new Block ( ) ; $ block -> setId ( uniqid ( ) ) ; $ block -> setSettings ( $ event -> getSettings ( ) ) ; $ block -> setType ( $ this -> blockService -> getName ( ) ) ; $ event -> addBlock ( $ block ) ; }
Add blocks services to event .
1,325
public function addParameter ( $ name , $ required = false , $ description = '' , $ default = null ) { $ this -> parameters [ $ name ] = [ 'name' => $ name , 'required' => $ required , 'description' => $ description , 'default' => $ default , 'value' => null ] ; return $ this ; }
Adds a parameter to the definition of the Task
1,326
public function hasParameter ( $ name ) { if ( array_key_exists ( $ name , $ this -> parameters ) ) { if ( null !== $ this -> parameters [ $ name ] [ 'value' ] ) { return true ; } } return false ; }
Returns true if the Task has a parameter with the given name and the value is not null . Returns false otherwise .
1,327
private function replaceTokens ( $ option ) { if ( is_array ( $ option ) ) { $ tokenizedOptions = [ ] ; foreach ( $ option as $ key => $ opt ) { $ tokenizedOptions [ $ key ] = $ this -> replaceTokens ( $ opt ) ; } return $ tokenizedOptions ; } return preg_replace_callback ( '/\$(.+)\$|\$\{(.+)\}/' , function ( $ match ) { $ val = isset ( $ match [ 2 ] ) ? getenv ( $ match [ 2 ] ) : getenv ( $ match [ 1 ] ) ; return $ val !== false ? $ val : $ match [ 0 ] ; } , $ option ) ; }
Tokenize the given option if it is a string .
1,328
public function getPath ( UriInterface $ uri ) { $ path = trim ( $ uri -> getPath ( ) , '/' ) ; $ parts = explode ( '/' , $ path ) ; if ( $ parts [ 0 ] === 'v' . Client :: API_VERSION ) { unset ( $ parts [ 0 ] ) ; } return '/' . implode ( '/' , $ parts ) ; }
Gets the path from a UriInterface instance after removing the version prefix .
1,329
public function getQueryParams ( UriInterface $ uri , $ exclude = [ 'sig' ] , $ params = [ ] ) { parse_str ( $ uri -> getQuery ( ) , $ params ) ; foreach ( $ exclude as $ excludedParam ) { if ( array_key_exists ( $ excludedParam , $ params ) ) { unset ( $ params [ $ excludedParam ] ) ; } } return $ params ; }
Gets the query parameters as an array from a UriInterface instance .
1,330
public function url ( ) { if ( $ this -> urlName ) return $ this -> urlName ; if ( $ this -> objectClass ) return $ this -> objectClass -> url ( $ this ) ; return null ; }
Returns the API url where you can receive this object .
1,331
public function refresh ( ) { $ response = $ this -> api -> get ( $ this -> url ( ) ) ; $ this -> data = ( array ) $ response -> data ; return $ this ; }
Makes a GET request and refreshes the local data with up - to - date info .
1,332
public static function init ( $ path ) { pake_mkdirs ( $ path ) ; pake_sh ( escapeshellarg ( pake_which ( 'hg' ) ) . ' init -q ' . escapeshellarg ( $ path ) ) ; return new pakeMercurial ( $ path ) ; }
new mercurial - repo
1,333
public function handle_options ( $ options = null ) { $ this -> opt = new pakeGetopt ( self :: $ OPTIONS ) ; $ this -> opt -> parse ( $ options ) ; foreach ( $ this -> opt -> get_options ( ) as $ opt => $ value ) { $ this -> do_option ( $ opt , $ value ) ; } }
Read and handle the command line options .
1,334
public function have_pakefile ( ) { $ is_windows = ( strtolower ( substr ( PHP_OS , 0 , 3 ) ) == 'win' ) ; $ here = getcwd ( ) ; foreach ( $ this -> PAKEFILES as $ file ) { $ path_includes_directory = basename ( $ file ) !== $ file ; if ( $ path_includes_directory ) { if ( $ is_windows ) { $ is_absolute_path = ( $ file [ 0 ] == '\\' or $ file [ 0 ] == '/' or mb_ereg ( '^[A-Za-z]+:' , $ file ) === 1 ) ; } else { $ is_absolute_path = $ file [ 0 ] == '/' ; } } else { $ is_absolute_path = false ; } if ( $ is_absolute_path ) { $ filepath = $ file ; } else { $ filepath = $ here . DIRECTORY_SEPARATOR . $ file ; } if ( file_exists ( $ filepath ) ) { $ this -> pakefile = realpath ( $ filepath ) ; return true ; } } return false ; }
If a match is found it is copied into
1,335
public function do_option ( $ opt , $ value ) { switch ( $ opt ) { case 'interactive' : $ this -> interactive = true ; break ; case 'dry-run' : $ this -> verbose = true ; $ this -> nowrite = true ; $ this -> dryrun = true ; $ this -> trace = true ; break ; case 'help' : $ this -> help ( ) ; exit ( ) ; case 'libdir' : set_include_path ( $ value . PATH_SEPARATOR . get_include_path ( ) ) ; break ; case 'nosearch' : $ this -> nosearch = true ; break ; case 'prereqs' : $ this -> show_prereqs = true ; break ; case 'quiet' : $ this -> verbose = false ; break ; case 'pakefile' : $ this -> PAKEFILES = array ( $ value ) ; break ; case 'require' : require $ value ; break ; case 'import' : pake_import ( $ value ) ; break ; case 'tasks' : $ this -> show_tasks = true ; break ; case 'trace' : $ this -> trace = true ; $ this -> verbose = true ; break ; case 'usage' : $ this -> usage ( ) ; exit ( ) ; case 'verbose' : $ this -> verbose = true ; break ; case 'force-tty' : define ( 'PAKE_FORCE_TTY' , true ) ; break ; case 'full-width' : $ this -> full_width = true ; break ; case 'version' : $ this -> showVersion ( ) ; exit ( ) ; default : throw new pakeException ( 'Unknown option: ' . $ opt ) ; } }
Do the option defined by + opt + and + value + .
1,336
public function help ( ) { $ this -> usage ( false ) ; echo "\n" ; echo "available options:" ; echo "\n" ; foreach ( self :: $ OPTIONS as $ option ) { list ( $ long , $ short , $ mode , $ comment ) = $ option ; if ( $ mode == pakeGetopt :: REQUIRED_ARGUMENT ) { if ( preg_match ( '/\b([A-Z]{2,})\b/' , $ comment , $ match ) ) $ long .= '=' . $ match [ 1 ] ; } printf ( " %-20s" , pakeColor :: colorize ( $ long , 'INFO' ) ) ; if ( ! empty ( $ short ) ) { printf ( " (%s)" , pakeColor :: colorize ( $ short , 'INFO' ) ) ; } printf ( "\n %s\n" , $ comment ) ; } }
Display the pake command line help .
1,337
public function display_tasks_and_comments ( ) { $ width = 0 ; $ tasks = pakeTask :: get_tasks ( ) ; foreach ( $ tasks as $ name => $ task ) { $ w = strlen ( pakeTask :: get_mini_task_name ( $ name ) ) ; if ( $ w > $ width ) $ width = $ w ; } $ width += mb_strlen ( pakeColor :: colorize ( ' ' , 'INFO' ) ) ; echo "available " . self :: $ EXEC_NAME . " tasks:\n" ; $ has_alias = false ; ksort ( $ tasks ) ; foreach ( $ tasks as $ name => $ task ) { if ( $ task -> get_alias ( ) ) { $ has_alias = true ; } if ( ! $ task -> get_alias ( ) and $ task -> get_comment ( ) ) { $ mini_name = pakeTask :: get_mini_task_name ( $ name ) ; printf ( ' %-' . $ width . 's > %s' . "\n" , pakeColor :: colorize ( $ mini_name , 'INFO' ) , $ task -> get_comment ( ) . ( $ mini_name != $ name ? ' [' . $ name . ']' : '' ) ) ; } } if ( $ has_alias ) { print ( "\ntask aliases:\n" ) ; foreach ( $ tasks as $ name => $ task ) { if ( $ task -> get_alias ( ) ) { $ mini_name = pakeTask :: get_mini_task_name ( $ name ) ; printf ( ' %-' . $ width . 's = ' . self :: $ EXEC_NAME . ' %s' . "\n" , pakeColor :: colorize ( pakeTask :: get_mini_task_name ( $ name ) , 'INFO' ) , $ task -> get_alias ( ) . ( $ mini_name != $ name ? ' [' . $ name . ']' : '' ) ) ; } } } echo "\n" . 'Try "' ; echo pakeColor :: colorize ( self :: $ EXEC_NAME . ' help taskname' , 'INFO' ) ; echo '" to get detailed information about task' . "\n\n" ; }
Display the tasks and dependencies .
1,338
public function display_prerequisites ( ) { foreach ( pakeTask :: get_tasks ( ) as $ name => $ task ) { echo self :: $ EXEC_NAME . " " . pakeTask :: get_mini_task_name ( $ name ) . "\n" ; foreach ( $ task -> get_prerequisites ( ) as $ prerequisite ) { echo " $prerequisite\n" ; } } }
Display the tasks and prerequisites
1,339
public static function run_help ( $ task , $ args ) { if ( count ( $ args ) == 0 ) { self :: get_instance ( ) -> help ( ) ; return ; } $ victim_name = $ args [ 0 ] ; $ task_name = pakeTask :: taskname_from_abbreviation ( $ victim_name ) ; $ victim = null ; foreach ( pakeTask :: get_tasks ( ) as $ name => $ task ) { if ( $ task_name == $ name or $ task_name == pakeTask :: get_mini_task_name ( $ name ) ) { $ victim = $ task ; break ; } } if ( null === $ victim ) { throw new pakeException ( "Couldn't find documentation for {$task_name}" ) ; } $ title = 'Documentation for "' . $ task_name . '" task' ; pake_echo ( $ title ) ; pake_echo ( str_repeat ( '=' , mb_strlen ( $ title ) ) ) ; pake_echo ( $ victim -> get_comment ( ) . "\n" ) ; pake_echo ( $ victim -> get_help ( ) ) ; }
show documentation ; use pake help taskname to see detailed documentation on task
1,340
public function findNextToken ( $ matcher ) { $ nextToken = $ this -> nextToken ; while ( null !== $ nextToken ) { if ( $ nextToken -> matches ( $ matcher ) ) { return new Some ( $ nextToken ) ; } $ nextToken = $ nextToken -> nextToken ; } return None :: create ( ) ; }
Finds the next token that satisfies the passed matcher .
1,341
public function findPreviousToken ( $ matcher ) { $ previousToken = $ this -> previousToken ; while ( null !== $ previousToken ) { if ( $ previousToken -> matches ( $ matcher ) ) { return new Some ( $ previousToken ) ; } $ previousToken = $ previousToken -> previousToken ; } return None :: create ( ) ; }
Finds the previous token that satisfies the passed matcher .
1,342
public function getIndentation ( ) { $ indentation = $ this -> getLineIndentation ( ) ; if ( $ this -> isFirstTokenOnLine ( ) && $ this -> matches ( T_WHITESPACE ) ) { $ indentation = '' ; } return $ indentation . str_repeat ( ' ' , $ this -> getStartColumn ( ) - strlen ( $ indentation ) ) ; }
Returns the indentation necessary to reach the start of this token on a new line .
1,343
public function getContentUntil ( AbstractToken $ token ) { if ( $ this === $ token ) { return '' ; } $ content = $ this -> getContent ( ) ; $ next = $ this -> nextToken ; while ( $ next && $ next !== $ token ) { $ content .= $ next -> getContent ( ) ; $ next = $ next -> nextToken ; } if ( null === $ next ) { throw new \ RuntimeException ( sprintf ( 'Could not find token "%s".' , $ token ) ) ; } return $ content ; }
Returns the content from this Token until the passed token .
1,344
public function getLineIndentation ( ) { $ first = $ this -> getFirstTokenOnLine ( ) ; if ( ! $ first -> matches ( T_WHITESPACE ) ) { return '' ; } return $ first -> getContentUntil ( $ first -> findNextToken ( 'NO_WHITESPACE' ) -> get ( ) ) ; }
Returns the indentation used on the current line .
1,345
public final function matches ( $ matcher ) { if ( is_string ( $ matcher ) && substr ( $ matcher , 0 , 3 ) === 'NO_' ) { return ! $ this -> matches ( substr ( $ matcher , 3 ) ) ; } if ( $ matcher === 'WHITESPACE_OR_COMMENT' ) { return $ this -> matches ( T_WHITESPACE ) || $ this -> matches ( T_COMMENT ) || $ this -> matches ( T_DOC_COMMENT ) ; } else if ( $ matcher === 'COMMENT' ) { return $ this -> matches ( T_COMMENT ) || $ this -> matches ( T_DOC_COMMENT ) ; } else if ( $ matcher === 'WHITESPACE' ) { return $ this -> matches ( T_WHITESPACE ) ; } else if ( $ matcher === 'END_OF_LINE' ) { return $ this -> isLastTokenOnLine ( ) ; } else if ( $ matcher === 'END_OF_NAME' ) { return ! $ this -> matches ( T_STRING ) && ! $ this -> matches ( T_NS_SEPARATOR ) ; } else if ( $ matcher === 'END_OF_CALL' ) { $ opened = 0 ; $ matcher = function ( AbstractToken $ token ) use ( & $ opened ) { switch ( true ) { case $ token -> matches ( ')' ) : return 0 === ( $ opened -- ) ; case $ token -> matches ( '(' ) : $ opened += 1 ; default : return false ; } } ; } if ( $ matcher instanceof \ Closure ) { return $ matcher ( $ this ) ; } return $ this -> matchesInternal ( $ matcher ) ; }
Returns whether this token matches the given token .
1,346
private function getOptions ( ) { $ inputString = ( string ) $ this -> input ; $ options = [ ] ; $ content = explode ( ' ' , $ inputString , 3 ) ; if ( sizeof ( $ content ) > 2 && strpos ( $ inputString , '=' ) === false ) { throw new \ Exception ( "Option syntax should contain an equal sign. Ex: --executable=php" ) ; } if ( sizeof ( $ content ) > 2 && strpos ( $ inputString , '--' ) === false ) { throw new \ Exception ( "Option syntax should contain double dashes. Ex: --executable=php" ) ; } $ pieces = explode ( '--' , $ content [ 2 ] ) ; array_shift ( $ pieces ) ; foreach ( $ pieces as $ piece ) { $ piece = trim ( $ piece ) ; list ( $ name , $ value ) = explode ( '=' , $ piece , 2 ) ; if ( strpos ( $ value , "'[" ) === 0 && strpos ( $ value , "]'" ) === ( strlen ( $ value ) - 2 ) ) { $ csv = trim ( str_replace ( [ '[' , ']' ] , '' , $ value ) , "'" ) ; $ value = str_getcsv ( $ csv , ',' ) ; } $ options [ $ name ] = $ value ; } return $ options ; }
This method takes the Argv and parses out all the options passed .
1,347
private function registerBreadcrumbsService ( ) { $ this -> singleton ( Contracts \ Breadcrumbs :: class , function ( $ app ) { $ config = $ app [ 'config' ] ; return new Breadcrumbs ( $ config -> get ( 'breadcrumbs.template.supported' , [ ] ) , $ config -> get ( 'breadcrumbs.template.default' , '' ) ) ; } ) ; }
Register the Breadcrumbs service .
1,348
public function compile ( ) { if ( null !== $ this -> parameterBag ) { $ blocks = $ this -> getCoreBlocks ( ) ; $ blocks = array_merge ( $ blocks , $ this -> getThirdPartyBlocks ( ) ) ; foreach ( $ blocks as $ block ) { $ this -> prepareBlock ( $ block ) ; } } Config :: read ( $ this ) ; parent :: compile ( ) ; }
Compiles the container with third party blocks
1,349
public function sendReminder ( $ method = null ) { if ( $ method ) { if ( ! in_array ( $ method , array ( 'Email' , 'Letter' ) ) ) throw new InvalidFieldValueError ( "'method' must be either " . "'Email' or 'Letter'" ) ; return $ this -> performEvent ( 'remind' , array ( 'method' => $ method ) ) ; } return $ this -> performEvent ( 'remind' ) ; }
Manually send a reminder if the billogram is overdue .
1,350
public function resend ( $ method = null ) { if ( $ method ) { if ( ! in_array ( $ method , array ( 'Email' , 'Letter' ) ) ) throw new InvalidFieldValueError ( "'method' must be either " . "'Email' or 'Letter'" ) ; return $ this -> performEvent ( 'resend' , array ( 'method' => $ method ) ) ; } return $ this -> performEvent ( 'resend' ) ; }
Resend a billogram via Email or Letter .
1,351
public function getInvoicePdf ( $ letterId = null , $ invoiceNo = null ) { $ params = array ( ) ; if ( $ letterId ) $ params [ 'letter_id' ] = $ letterId ; if ( $ invoiceNo ) $ params [ 'invoice_no' ] = $ invoiceNo ; $ response = $ this -> api -> get ( $ this -> url ( ) . '.pdf' , $ params , 'application/json' ) ; return base64_decode ( $ response -> data -> content ) ; }
Returns the PDF - file content for a specific billogram invoice or letter document . Will throw a ObjectNotFoundError with message Object not available yet if the PDF has not yet been generated .
1,352
public function getAttachmentPdf ( ) { $ response = $ this -> api -> get ( $ this -> url ( ) . '/attachment.pdf' , null , 'application/json' ) ; return base64_decode ( $ response -> data -> content ) ; }
Returns the PDF - file content for the billogram s attachment .
1,353
public function attachPdf ( $ filepath ) { $ content = file_get_contents ( $ filepath ) ; $ filename = basename ( $ filepath ) ; return $ this -> performEvent ( 'attach' , array ( 'filename' => $ filename , 'content' => base64_encode ( $ content ) ) ) ; }
Attach a PDF to the billogram .
1,354
public static function settings ( $ settings = null ) { if ( $ settings ) { self :: $ settings = self :: mergeSettings ( self :: $ settings , $ settings ) ; } else { } return self :: $ settings ; }
Config setter & getter This serves as a settings setter and getter at the same time
1,355
protected static function mergeSettings ( $ Arr1 , $ Arr2 ) { foreach ( $ Arr2 as $ key => $ Value ) { if ( array_key_exists ( $ key , $ Arr1 ) && is_array ( $ Value ) ) { $ Arr1 [ $ key ] = self :: mergeSettings ( $ Arr1 [ $ key ] , $ Arr2 [ $ key ] ) ; } else { $ Arr1 [ $ key ] = $ Value ; } } return $ Arr1 ; }
method for merging setting files
1,356
public static function subpackage_settings ( $ subpackage ) { $ s = self :: settings ( ) ; if ( isset ( $ s [ $ subpackage ] ) ) { return $ s [ $ subpackage ] ; } }
Getter for subpackage specific settings
1,357
public static function subpackage_setting ( $ subpackage , $ setting ) { $ s = self :: subpackage_settings ( $ subpackage ) ; if ( isset ( $ s [ $ setting ] ) ) { return $ s [ $ setting ] ; } }
Getter for a specific setting from a subpackage
1,358
public static function init ( $ settings = null ) { if ( is_array ( $ settings ) ) { $ settings = self :: settings ( $ settings ) ; } else { $ settings = self :: settings ( ) ; } if ( $ settings [ 'enabled' ] ) { $ ssversion = self :: subpackage_settings ( 'ssversion' ) ; if ( self :: subpackage_enabled ( 'calendars' ) ) { if ( $ ssversion == '3.0' ) { Object :: add_extension ( 'Event' , 'EventCalendarExtension' ) ; } else { Event :: add_extension ( 'EventCalendarExtension' ) ; } $ s = self :: subpackage_settings ( 'calendars' ) ; if ( $ s [ 'colors' ] ) { if ( $ ssversion == '3.0' ) { Object :: add_extension ( 'Calendar' , 'CalendarColorExtension' ) ; } else { Calendar :: add_extension ( 'CalendarColorExtension' ) ; } } if ( $ s [ 'shading' ] ) { if ( $ ssversion == '3.0' ) { Object :: add_extension ( 'Calendar' , 'ShadedCalendarExtension' ) ; } else { Calendar :: add_extension ( 'ShadedCalendarExtension' ) ; } } } if ( self :: subpackage_enabled ( 'categories' ) ) { if ( $ ssversion == '3.0' ) { Object :: add_extension ( 'Event' , 'EventCategoryExtension' ) ; } else { Event :: add_extension ( 'EventCategoryExtension' ) ; } } if ( self :: subpackage_setting ( 'pagetypes' , 'enable_eventpage' ) ) { if ( $ ssversion == '3.0' ) { Object :: add_extension ( 'Event' , 'EventHasEventPageExtension' ) ; } else { Event :: add_extension ( 'EventHasEventPageExtension' ) ; } } if ( self :: subpackage_enabled ( 'debug' ) ) { if ( $ ssversion == '3.0' ) { Object :: add_extension ( 'Event' , 'EventDebugExtension' ) ; } else { Event :: add_extension ( 'EventDebugExtension' ) ; } } if ( self :: subpackage_enabled ( 'registrations' ) ) { if ( $ ssversion == '3.0' ) { Object :: add_extension ( 'Event' , 'EventRegistrationExtension' ) ; } else { Event :: add_extension ( 'EventRegistrationExtension' ) ; } } Object :: add_extension ( 'Calendar' , 'DoURLSegmentExtension' ) ; if ( $ ssversion == '3.0' ) { Object :: add_extension ( 'Calendar' , 'DoURLSegmentExtension' ) ; } else { Calendar :: add_extension ( 'DoURLSegmentExtension' ) ; } } }
Calendar initialization Should be called from the project _config . php file
1,359
public function formatQueryResult ( QueryResultInterface $ result , OutputInterface $ output , $ elapsed ) { $ table = new Table ( $ output ) ; $ table -> setHeaders ( array_merge ( [ 'Path' , ] , $ result -> getColumnNames ( ) ) ) ; foreach ( $ result -> getRows ( ) as $ row ) { $ values = array_merge ( [ $ row -> getPath ( ) , ] , $ row -> getValues ( ) ) ; foreach ( $ values as & $ value ) { if ( $ value instanceof \ DateTime ) { $ value = $ value -> format ( 'c' ) ; continue ; } $ value = $ this -> textHelper -> truncate ( $ value , 255 ) ; } $ table -> addRow ( $ values ) ; } $ table -> render ( $ output ) ; if ( true === $ this -> config [ 'show_execution_time_query' ] ) { $ output -> writeln ( sprintf ( '%s rows in set (%s sec)' , count ( $ result -> getRows ( ) ) , number_format ( $ elapsed , $ this -> config [ 'execution_time_expansion' ] ) ) ) ; } }
Render a table with the results of the given QueryResultInterface .
1,360
public static function type ( $ name ) { $ finder = new pakeFinder ( ) ; if ( strtolower ( substr ( $ name , 0 , 3 ) ) == 'dir' ) { $ finder -> type = 'directory' ; } else { if ( strtolower ( $ name ) == 'any' ) { $ finder -> type = 'any' ; } else { $ finder -> type = 'file' ; } } return $ finder ; }
Factory which prepares new pakeFinder objects Sets the type of elements to return .
1,361
private function pattern_to_regex ( $ pattern ) { if ( substr ( $ pattern , - 1 ) == '/' ) { $ pattern .= '**' ; } $ regex = '|^' ; foreach ( explode ( '/' , $ pattern ) as $ i => $ piece ) { if ( $ i > 0 ) { $ regex .= preg_quote ( '/' , '|' ) ; } if ( '**' == $ piece ) { $ regex .= '.*' ; } else { $ regex .= str_replace ( array ( '?' , '*' ) , array ( '[^/]' , '[^/]*' ) , $ piece ) ; } } $ regex .= '$|' ; return $ regex ; }
converts ant - pattern to PCRE regex
1,362
public function pattern ( ) { $ patterns = func_get_args ( ) ; foreach ( func_get_args ( ) as $ pattern ) { $ this -> patterns [ ] = $ this -> pattern_to_regex ( $ pattern ) ; } return $ this ; }
Mimics ant pattern matching .
1,363
public function not_name ( ) { $ args = func_get_args ( ) ; $ this -> names = array_merge ( $ this -> names , $ this -> args_to_array ( $ args , true ) ) ; return $ this ; }
Adds rules that files must not match .
1,364
public function prune ( ) { $ args = func_get_args ( ) ; $ this -> prunes = array_merge ( $ this -> prunes , $ this -> args_to_array ( $ args ) ) ; return $ this ; }
Traverses no further .
1,365
public function discard ( ) { $ args = func_get_args ( ) ; $ this -> discards = array_merge ( $ this -> discards , $ this -> args_to_array ( $ args ) ) ; return $ this ; }
Discards elements that matches .
1,366
public function exec ( ) { $ args = func_get_args ( ) ; for ( $ i = 0 ; $ i < count ( $ args ) ; $ i ++ ) { if ( is_array ( $ args [ $ i ] ) && ! method_exists ( $ args [ $ i ] [ 0 ] , $ args [ $ i ] [ 1 ] ) ) { throw new pakeException ( 'Method ' . $ args [ $ i ] [ 1 ] . ' does not exist for object ' . $ args [ $ i ] [ 0 ] ) ; } else { if ( ! is_array ( $ args [ $ i ] ) && ! function_exists ( $ args [ $ i ] ) ) { throw new pakeException ( 'Function ' . $ args [ $ i ] . ' does not exist.' ) ; } } $ this -> execs [ ] = $ args [ $ i ] ; } return $ this ; }
Executes function or method for each element .
1,367
public function create ( $ data ) { $ response = $ this -> api -> post ( $ this -> url ( ) , $ data ) ; $ className = $ this -> objectClass ; return new $ className ( $ this -> api , $ this , $ response -> data ) ; }
Makes a POST request to the API and creates a new object .
1,368
public function url ( $ object = null ) { if ( is_object ( $ object ) ) { $ objectIdField = $ this -> objectIdField ; return $ this -> urlName . '/' . $ object -> $ objectIdField ; } elseif ( $ object ) { return $ this -> urlName . '/' . $ object ; } return $ this -> urlName ; }
Formats and returns a URL to an object or object id .
1,369
public function assertNodeIsVersionable ( NodeInterface $ node ) { if ( ! $ this -> nodeHasMixinType ( $ node , 'mix:versionable' ) ) { throw new \ OutOfBoundsException ( sprintf ( 'Node "%s" is not versionable' , $ node -> getPath ( ) ) ) ; } }
Return true if the given node is versionable .
1,370
public function has ( $ key ) : bool { return $ this -> exists ( $ key ) && null !== $ this -> attributes [ $ key ] ; }
Checks if an a key is present and not null .
1,371
public function setRequestOnHandler ( $ request ) { if ( $ this -> handlerNeedsRequest ( ) ) { $ handler = $ this -> getHandler ( ) ; $ handler -> setRequest ( $ request ) ; } }
Set the request on the handler instance .
1,372
public function getColorWithHash ( ) { $ color = $ this -> owner -> Color ; if ( strpos ( $ color , '#' ) === false ) { return '#' . $ color ; } else { return $ color ; } }
Getter that always returns the color with a hash As the standard Silverstripe color picker seems to save colors without a hash this just makes sure that colors are always returned with a hash - whether they ve been saved with or without one
1,373
protected function mapRequestToFile ( $ method , $ uri , $ parameters ) { $ filename = strtolower ( $ method ) . '_' ; $ filename .= $ this -> cleanPath ( $ uri ) ; $ suffix = $ this -> mapRequestParameters ( $ parameters ) ; return $ this -> fixturesPath . $ filename . $ suffix . '.json' ; }
Parse the correct filename from the request .
1,374
protected function cleanPath ( $ uri ) { $ urlPath = parse_url ( $ uri , PHP_URL_PATH ) ; $ uri = str_replace ( 'v1/' , '' , $ urlPath ) ; $ path = preg_replace ( '/(\/\w{10}$|self|\d*)/' , '' , $ uri ) ; return trim ( preg_replace ( '/\/{1,2}|\-/' , '_' , $ path ) , '_' ) ; }
Removes any unwanted suffixes and values from a URL path .
1,375
protected function mapRequestParameters ( $ parameters ) { if ( empty ( $ parameters ) || ! array_key_exists ( 'query' , $ parameters ) ) { return '' ; } $ exclude = [ 'q' , 'count' , 'min_id' , 'max_id' , 'min_tag_id' , 'max_tag_id' , 'lat' , 'lng' , 'distance' , 'text' , 'max_like_id' , 'action' , 'cursor' , 'access_token' , ] ; $ modifiers = array_except ( $ parameters [ 'query' ] , $ exclude ) ; $ return = implode ( '_' , array_keys ( $ modifiers ) ) ; return rtrim ( "_$return" , '_' ) ; }
Parses any filename properties from the request parameters .
1,376
private function getOldFacetParams ( array $ facetBuilders ) { $ facetParamsGrouped = array_map ( function ( $ facetBuilder ) { return $ this -> facetBuilderVisitor -> visitBuilder ( $ facetBuilder , spl_object_hash ( $ facetBuilder ) ) ; } , $ this -> filterOldFacetBuilders ( $ facetBuilders ) ) ; return $ this -> formatOldFacetParams ( $ facetParamsGrouped ) ; }
Converts an array of facet builder objects to a Solr query parameters representation .
1,377
public function getRaw ( $ key = null ) { return $ key === null ? $ this -> raw : $ this -> raw [ $ key ] ; }
Gets the JSON - decoded raw response .
1,378
public function get ( ) { return $ this -> isCollection ( $ this -> data ) ? new Collection ( $ this -> data ) : $ this -> data ; }
Gets the response body . If the response contains multiple records a Collection is returned .
1,379
protected function isCollection ( $ data ) { $ isCollection = false ; if ( $ data === null ) { return $ isCollection ; } if ( ! $ this -> isRecord ( $ data ) ) { $ isCollection = true ; } return $ isCollection ; }
Tests the current response data to see if one or more records were returned .
1,380
protected function isRecord ( $ data ) { if ( $ data instanceof Collection ) { return false ; } $ keys = array_keys ( $ data ) ; return ( in_array ( 'id' , $ keys , true ) || in_array ( 'name' , $ keys , true ) ) ; }
Tests the current response data to see if a single record was returned .
1,381
protected function registerBreadcrumbs ( $ container , array $ item = [ ] ) { $ this -> setBreadcrumbsContainer ( $ container ) ; breadcrumbs ( ) -> register ( 'main' , function ( Builder $ bc ) use ( $ item ) { if ( empty ( $ item ) ) { $ item = $ this -> getBreadcrumbsHomeItem ( ) ; } $ bc -> push ( $ item [ 'title' ] , $ item [ 'url' ] , $ item [ 'data' ] ?? [ ] ) ; } ) ; }
Register a breadcrumb .
1,382
protected function loadBreadcrumbs ( ) { breadcrumbs ( ) -> register ( $ this -> breadcrumbsContainer , function ( Builder $ bc ) { $ bc -> parent ( 'main' ) ; if ( ! empty ( $ this -> breadcrumbsItems ) ) { foreach ( $ this -> breadcrumbsItems as $ crumb ) { $ bc -> push ( $ crumb [ 'title' ] , $ crumb [ 'url' ] , $ crumb [ 'data' ] ?? [ ] ) ; } } } ) ; }
Load all breadcrumbs .
1,383
protected function addBreadcrumbRoute ( $ title , $ route , array $ parameters = [ ] , array $ data = [ ] ) { return $ this -> addBreadcrumb ( $ title , route ( $ route , $ parameters ) , $ data ) ; }
Add breadcrumb with route .
1,384
protected function generateSig ( $ endpoint , array $ params , $ secret ) { $ sig = $ endpoint ; ksort ( $ params ) ; foreach ( $ params as $ key => $ val ) { $ sig .= "|$key=$val" ; } return hash_hmac ( 'sha256' , $ sig , $ secret , false ) ; }
Generates a sig value for a request .
1,385
protected function loadFile ( $ file ) { if ( ! stream_is_local ( $ file ) ) { throw new InvalidArgumentException ( sprintf ( 'This is not a local file "%s".' , $ file ) ) ; } if ( ! file_exists ( $ file ) ) { throw new InvalidArgumentException ( sprintf ( 'The service file "%s" is not valid.' , $ file ) ) ; } if ( null === $ this -> jsonParser ) { $ this -> jsonParser = new Json ( ) ; } return $ this -> validate ( $ this -> jsonParser -> decode ( file_get_contents ( $ file ) , true ) , $ file ) ; }
Loads the Json File
1,386
public function getRecentMedia ( $ id , $ minId = null , $ maxId = null ) { $ params = [ 'query' => [ 'min_id' => $ minId , 'max_id' => $ maxId , ] ] ; return $ this -> client -> request ( 'GET' , "locations/$id/media/recent" , $ params ) ; }
Get a list of recent media objects from a given location .
1,387
public function search ( $ latitude , $ longitude , $ distance = 1000 ) { $ params = [ 'query' => [ 'lat' => $ latitude , 'lng' => $ longitude , 'distance' => $ distance , ] ] ; return $ this -> client -> request ( 'GET' , 'locations/search' , $ params ) ; }
Search for a location by geographic coordinate .
1,388
private function isPropertyEditable ( PropertyInterface $ property ) { if ( false === $ this -> allowBinary && PropertyType :: BINARY == $ property -> getType ( ) ) { $ this -> notes [ ] = sprintf ( 'Binary property "%s" has been omitted' , $ property -> getName ( ) ) ; return false ; } return true ; }
Return false if property type is not editable .
1,389
public function update ( $ taskId , array $ data ) { $ data = self :: mergeData ( $ data , [ 'finished' => false , 'smContactTaskReq' => [ 'id' => $ taskId , ] , ] ) ; return $ this -> client -> doPost ( 'contact/updateTask' , $ data ) ; }
Update task .
1,390
static protected function parseMapping ( $ mapping , & $ i = 0 ) { $ output = array ( ) ; $ len = strlen ( $ mapping ) ; $ i += 1 ; while ( $ i < $ len ) { switch ( $ mapping [ $ i ] ) { case ' ' : case ',' : ++ $ i ; continue 2 ; case '}' : return $ output ; } $ key = self :: parseScalar ( $ mapping , array ( ':' , ' ' ) , array ( '"' , "'" ) , $ i , false ) ; $ done = false ; while ( $ i < $ len ) { switch ( $ mapping [ $ i ] ) { case '[' : $ output [ $ key ] = self :: parseSequence ( $ mapping , $ i ) ; $ done = true ; break ; case '{' : $ output [ $ key ] = self :: parseMapping ( $ mapping , $ i ) ; $ done = true ; break ; case ':' : case ' ' : break ; default : $ output [ $ key ] = self :: parseScalar ( $ mapping , array ( ',' , '}' ) , array ( '"' , "'" ) , $ i ) ; $ done = true ; -- $ i ; } ++ $ i ; if ( $ done ) { continue 2 ; } } } throw new InvalidArgumentException ( sprintf ( 'Malformed inline YAML string %s' , $ mapping ) ) ; }
Parses a mapping to a YAML string .
1,391
public function findAverageNote ( Thread $ thread ) { return $ this -> repository -> createQueryBuilder ( 'c' ) -> select ( 'avg(c.note)' ) -> where ( 'c.private <> :private' ) -> andWhere ( 'c.thread = :thread' ) -> setParameters ( [ 'private' => 1 , 'thread' => $ thread , ] ) -> getQuery ( ) -> getSingleScalarResult ( ) ; }
Returns Thread average note .
1,392
protected function resolveExceptionClass ( ClientException $ exception ) { $ response = $ exception -> getResponse ( ) -> getBody ( ) ; $ response = json_decode ( $ response -> getContents ( ) ) ; if ( $ response === null ) { return new Exception ( $ exception -> getMessage ( ) ) ; } $ meta = isset ( $ response -> meta ) ? $ response -> meta : $ response ; $ class = '\\Larabros\\Elogram\\Exceptions\\' . $ meta -> error_type ; return new $ class ( $ meta -> error_message ) ; }
Parses a ClientException for any specific exceptions thrown by the API in the response body . If the response body is not in JSON format an Exception is returned .
1,393
public function git_run ( $ command ) { $ git = escapeshellarg ( pake_which ( 'git' ) ) ; if ( self :: $ needs_work_tree_workaround === true ) { $ cmd = '(cd ' . escapeshellarg ( $ this -> repository_path ) . ' && ' . $ git . ' ' . $ command . ')' ; } else { $ cmd = $ git ; $ cmd .= ' --git-dir=' . escapeshellarg ( $ this -> repository_path . '/.git' ) ; $ cmd .= ' --work-tree=' . escapeshellarg ( $ this -> repository_path ) ; $ cmd .= ' ' . $ command ; } try { return pake_sh ( $ cmd ) ; } catch ( pakeException $ e ) { if ( strpos ( $ e -> getMessage ( ) , 'cannot be used without a working tree' ) !== false || strpos ( $ e -> getMessage ( ) , 'fatal: Could not switch to ' ) !== false ) { pake_echo_error ( 'Your version of git is buggy. Using workaround' ) ; self :: $ needs_work_tree_workaround = true ; return $ this -> git_run ( $ command ) ; } throw $ e ; } }
Run git - command in context of repository
1,394
public static function init ( $ path , $ template_path = null , $ shared = false ) { pake_mkdirs ( $ path ) ; if ( false === $ shared ) $ shared = 'false' ; elseif ( true === $ shared ) $ shared = 'true' ; elseif ( is_int ( $ shared ) ) $ shared = sprintf ( "%o" , $ shared ) ; $ cmd = escapeshellarg ( pake_which ( 'git' ) ) . ' init -q' ; if ( null !== $ template_path ) { $ cmd .= ' --template=' . escapeshellarg ( $ template_path ) ; } $ cmd .= ' --shared=' . escapeshellarg ( $ shared ) ; $ cwd = getcwd ( ) ; chdir ( $ path ) ; chdir ( '.' ) ; pake_sh ( $ cmd ) ; chdir ( $ cwd ) ; return new pakeGit ( $ path ) ; }
new git - repo
1,395
public function renderEntryElementMap ( array & $ context ) { $ map = $ this -> renderer -> getElementMap ( $ context [ 'entry' ] [ 'id' ] , $ context [ 'site' ] [ 'id' ] ) ; return $ this -> renderMap ( $ map ) ; }
Renders the element map for an entry within the entry editor given the current Twig context .
1,396
public function renderCategoryElementMap ( array & $ context ) { $ map = $ this -> renderer -> getElementMap ( $ context [ 'category' ] [ 'id' ] , $ context [ 'site' ] [ 'id' ] ) ; return $ this -> renderMap ( $ map ) ; }
Renders the element map for a category within the category editor given the current Twig context .
1,397
public function renderUserElementMap ( array & $ context ) { $ map = $ this -> renderer -> getElementMap ( $ context [ 'user' ] [ 'id' ] , Craft :: $ app -> getSites ( ) -> getPrimarySite ( ) -> id ) ; return $ this -> renderMap ( $ map ) ; }
Renders the element map for a user within the user editor given the current Twig context .
1,398
public function renderProductElementMap ( array & $ context ) { $ map = $ this -> renderer -> getElementMap ( $ context [ 'product' ] [ 'id' ] , $ context [ 'site' ] [ 'id' ] ) ; return $ this -> renderMap ( $ map ) ; }
Renders the element map for a product within the product editor given the current Twig context .
1,399
public static function formatted_dates ( $ startObj , $ endObj ) { $ endDateIsset = true ; if ( isset ( $ endObj -> value ) ) { $ endDateIsset = false ; } $ startTime = strtotime ( $ startObj -> value ) ; $ endTime = strtotime ( $ endObj -> value ) ; $ startMonth = date ( 'M' , $ startTime ) ; $ startDayOfMonth = $ startObj -> DayOfMonth ( true ) ; $ str = $ startMonth . ' ' . $ startDayOfMonth ; if ( date ( 'Y-m-d' , $ startTime ) == date ( 'Y-m-d' , $ endTime ) ) { } else { if ( $ endDateIsset ) { $ endMonth = date ( 'M' , $ endTime ) ; $ endDayOfMonth = $ endObj -> DayOfMonth ( true ) ; if ( $ startMonth == $ endMonth ) { $ str .= ' - ' . $ endDayOfMonth ; } else { $ str .= ' - ' . $ endMonth . ' ' . $ endDayOfMonth ; } } } return $ str ; }
Formatted Dates Returns either the event s date or both start and end date if the event spans more than one date