idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
56,700 | public function create_scan_form ( $ params = null ) { $ requestor = new Requestor ( $ this -> _apiKey ) ; $ url = $ this -> instanceUrl ( ) . '/scan_form' ; list ( $ response , $ apiKey ) = $ requestor -> request ( 'post' , $ url , $ params ) ; return Util :: convertToEasyPostObject ( $ response , $ apiKey ) ; } | create a batch scan form |
56,701 | public static function all_api_keys ( $ apiKey = null ) { $ requestor = new Requestor ( $ apiKey ) ; list ( $ response , $ apiKey ) = $ requestor -> request ( 'get' , '/api_keys' ) ; return Util :: convertToEasyPostObject ( $ response , $ apiKey ) ; } | get all API keys |
56,702 | public static function create ( $ params = null , $ apiKey = null ) { if ( ! isset ( $ params [ 'report' ] ) || ! is_array ( $ params [ 'report' ] ) ) { $ clone = $ params ; unset ( $ params ) ; $ params [ 'report' ] = $ clone ; } if ( ! isset ( $ params [ 'report' ] [ 'type' ] ) ) { throw new Error ( 'Undetermined Rep... | create a report |
56,703 | protected static function reportUrl ( $ type ) { if ( $ postfix = strrchr ( $ type , '\\' ) ) { $ type = substr ( $ postfix , 1 ) ; } if ( substr ( $ type , 0 , strlen ( 'EasyPost' ) ) == 'EasyPost' ) { $ type = substr ( $ type , strlen ( 'EasyPost' ) ) ; } $ type = substr ( $ type , 0 , 1 ) . preg_replace ( '/([A-Z])/... | generate report url format |
56,704 | public function buy ( $ params = null ) { $ requestor = new Requestor ( $ this -> _apiKey ) ; $ url = $ this -> instanceUrl ( ) . '/buy' ; if ( $ params instanceof Rate ) { $ clone = $ params ; unset ( $ params ) ; $ params [ 'carrier' ] = $ clone -> carrier ; $ params [ 'service' ] = $ clone -> service ; } list ( $ re... | buy an order |
56,705 | public static function convertEasyPostObjectToArray ( $ values ) { $ results = array ( ) ; foreach ( $ values as $ k => $ v ) { if ( $ v instanceof EasyPostObject ) { $ results [ $ k ] = $ v -> __toArray ( true ) ; } else if ( is_array ( $ v ) ) { $ results [ $ k ] = self :: convertEasyPostObjectToArray ( $ v ) ; } els... | convert EasyPost object to an array |
56,706 | public static function convertToEasyPostObject ( $ response , $ apiKey , $ parent = null , $ name = null ) { $ types = array ( 'Address' => '\EasyPost\Address' , 'Batch' => '\EasyPost\Batch' , 'CarrierAccount' => '\EasyPost\CarrierAccount' , 'Container' => '\EasyPost\Container' , 'CustomsInfo' => '\EasyPost\CustomsInfo... | convert input to an EasyPost object |
56,707 | public static function types ( $ params = null , $ apiKey = null ) { $ requestor = new Requestor ( $ apiKey ) ; list ( $ response , $ apiKey ) = $ requestor -> request ( 'get' , '/carrier_types' , $ params ) ; return Util :: convertToEasyPostObject ( $ response , $ apiKey ) ; } | get types of carrier account |
56,708 | public static function create ( $ params = null , $ apiKey = null ) { $ urlMod = "" ; if ( ( isset ( $ params [ 'verify' ] ) && is_array ( $ params [ 'verify' ] ) ) || ( isset ( $ params [ 'verify_strict' ] ) && is_array ( $ params [ 'verify_strict' ] ) ) ) { $ verify = "" ; if ( isset ( $ params [ 'verify' ] ) ) { $ v... | create an address |
56,709 | public static function create_and_verify ( $ params = null , $ apiKey = null ) { $ class = get_class ( ) ; if ( ! isset ( $ params [ 'address' ] ) || ! is_array ( $ params [ 'address' ] ) ) { $ clone = $ params ; unset ( $ params ) ; $ params [ 'address' ] = $ clone ; } $ requestor = new Requestor ( $ apiKey ) ; $ url ... | create and verify an address |
56,710 | public function verify ( $ params = null ) { $ requestor = new Requestor ( $ this -> _apiKey ) ; $ url = $ this -> instanceUrl ( ) . '/verify' ; list ( $ response , $ apiKey ) = $ requestor -> request ( 'get' , $ url , $ params ) ; if ( isset ( $ response [ 'address' ] ) ) { $ verified_address = Util :: convertToEasyPo... | verify an address |
56,711 | public function prettyPrint ( ) { print ( $ this -> ecode . " (" . $ this -> getHttpStatus ( ) . "): " . $ this -> getMessage ( ) . "\n" ) ; if ( ! empty ( $ this -> errors ) ) { print ( "Field errors:\n" ) ; foreach ( $ this -> errors as $ field_error ) { foreach ( $ field_error as $ k => $ v ) { print ( " " . $ k . ... | print out the error |
56,712 | public function __toArray ( $ recursive = false ) { if ( $ recursive ) { return Util :: convertEasyPostObjectToArray ( $ this -> _values ) ; } return $ this -> _values ; } | convert object to an array |
56,713 | public function barcode ( $ params = null ) { $ requestor = new Requestor ( $ this -> _apiKey ) ; $ url = $ this -> instanceUrl ( ) . '/barcode' ; list ( $ response , $ apiKey ) = $ requestor -> request ( 'get' , $ url , $ params ) ; return $ response [ 'barcode_url' ] ; } | get the shipment barcode |
56,714 | public static function receive ( $ rawInput = null ) { if ( $ rawInput == null ) throw new Error ( 'The raw input must be set' ) ; $ values = json_decode ( $ rawInput , TRUE ) ; if ( $ values != null ) { return self :: constructFrom ( $ values , get_class ( ) , null ) ; } else { throw new Error ( 'There was a problem d... | receive an event |
56,715 | public function loadClassMetadata ( LoadClassMetadataEventArgs $ args ) { $ classMetadata = $ args -> getClassMetadata ( ) ; if ( $ classMetadata -> isInheritanceTypeSingleTable ( ) && ! $ classMetadata -> isRootEntity ( ) ) { return ; } if ( $ classMetadata -> getReflectionClass ( ) && $ classMetadata -> getReflection... | Loads class metadata and updates table prefix name . |
56,716 | public function getMetaValue ( $ name ) { foreach ( $ this -> getMetas ( ) as $ meta ) { if ( $ name == $ meta -> getKey ( ) ) { return $ meta -> getValue ( ) ; } } return ; } | Returns user meta value from a meta key name . |
56,717 | public function getParameter ( $ index ) { if ( ! $ this -> hasParameter ( $ index ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Cannot retrieve parameter "%s"' , $ index ) ) ; } return $ this -> parameters [ $ index ] ; } | Returns a parameter of given index position . |
56,718 | public function process ( ContainerBuilder $ container ) { if ( ! $ container -> hasParameter ( $ this -> enabledParameter ) ) { return ; } $ chainDriverDefService = $ this -> getChainDriverServiceName ( $ container ) ; $ chainDriverDef = $ container -> getDefinition ( $ chainDriverDefService ) ; foreach ( $ this -> na... | Register mappings with the metadata drivers . |
56,719 | public function onLogin ( WordpressEvent $ event ) { $ wpUser = $ event -> getParameter ( 'user' ) ; $ user = $ this -> userManager -> find ( $ wpUser -> data -> ID ) ; $ user -> setWordpressRoles ( $ wpUser -> roles ) ; $ token = new UsernamePasswordToken ( $ user , $ user -> getPass ( ) , $ this -> firewall , $ user ... | Wordpress user login hook method . |
56,720 | public function onLogout ( WordpressEvent $ event ) { $ this -> session -> clear ( ) ; $ this -> tokenStorage -> setToken ( null ) ; } | Wordpress user log out hook method . |
56,721 | private function createRedirectResponse ( Request $ request ) { $ url = $ this -> loginUrl . '?' . http_build_query ( [ 'redirect_to' => $ request -> getUri ( ) , 'reauth' => 0 , ] ) ; return RedirectResponse :: create ( $ url , 302 ) ; } | Creates a redirect response from the given request . |
56,722 | public function loadWordpress ( ) { if ( ! $ this -> alreadyInitialized ) { foreach ( $ this -> globals as $ globalVariable ) { global $ { $ globalVariable } ; } $ loader = $ this -> getWordpressDirectory ( ) . 'wp-blog-header.php' ; if ( ! file_exists ( $ loader ) ) { throw new \ InvalidArgumentException ( sprintf ( '... | Loads Wordpress . |
56,723 | public function setRoles ( $ roles ) { if ( ! is_array ( $ roles ) ) { $ roles = [ $ roles ] ; } $ this -> roles = $ roles ; return $ this ; } | Sets user roles . |
56,724 | public function setWordpressRoles ( array $ roles , $ prefix = 'ROLE_WP_' ) { foreach ( $ roles as $ key => $ role ) { $ roles [ $ key ] = $ prefix . strtoupper ( $ role ) ; } $ this -> setRoles ( $ roles ) ; return $ this ; } | Sets Wordpress user roles by prefixing them . |
56,725 | protected function loadTablePrefix ( ContainerBuilder $ container , $ prefix ) { $ identifier = 'ekino.wordpress.subscriber.table_prefix_subscriber' ; $ serviceDefinition = $ container -> getDefinition ( $ identifier ) ; $ serviceDefinition -> setArguments ( [ $ prefix ] ) ; $ container -> setDefinition ( $ identifier ... | Loads table prefix from configuration to doctrine table prefix subscriber event . |
56,726 | protected function loadEntityManager ( ContainerBuilder $ container , $ em ) { $ container -> setParameter ( 'ekino_wordpress.model_manager_name' , $ em ) ; $ reference = new Reference ( sprintf ( 'doctrine.orm.%s_entity_manager' , $ em ) ) ; foreach ( static :: $ entities as $ entityName ) { $ container -> findDefinit... | Sets Doctrine entity manager for Wordpress . |
56,727 | protected function loadWordpressGlobals ( ContainerBuilder $ container , $ globals ) { $ coreGlobals = [ 'wp' , 'wp_the_query' , 'wpdb' , 'wp_query' , 'allowedentitynames' ] ; $ globals = array_merge ( $ globals , $ coreGlobals ) ; $ container -> setParameter ( 'ekino.wordpress.globals' , $ globals ) ; } | Sets global variables array to load . |
56,728 | public function onKernelRequest ( GetResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; if ( 'ekino_wordpress_catchall' !== $ request -> attributes -> get ( '_route' ) ) { $ this -> wordpress -> loadWordpress ( ) ; } $ this -> checkAuthentication ( $ request ) ; } | On kernel request method . |
56,729 | protected function checkAuthentication ( Request $ request ) { if ( ! $ request -> hasPreviousSession ( ) ) { return ; } $ session = $ request -> getSession ( ) ; if ( $ session -> has ( 'token' ) ) { $ token = $ session -> get ( 'token' ) ; $ this -> tokenStorage -> setToken ( $ token ) ; } } | Checks if a Wordpress user is authenticated and authenticate him into Symfony security context . |
56,730 | private function toEntity ( ClassMetadataInfo $ metadata ) { foreach ( $ this -> classes as $ name => $ class ) { if ( ! is_array ( $ class ) || $ class [ 'class' ] != $ metadata -> getName ( ) ) { continue ; } if ( isset ( $ class [ 'class' ] ) ) { $ metadata -> isMappedSuperclass = false ; } if ( isset ( $ class [ 'r... | Transform a mapped superclass into entity if needed . |
56,731 | public function findByDate ( \ DateTime $ date = null ) { $ date = $ date ? : new \ DateTime ( ) ; return $ this -> repository -> findByDate ( $ date ) ; } | Returns posts for current date or a specified date . |
56,732 | private function prioritiseJobs ( ) { $ background = [ ] ; $ foreground = [ ] ; foreach ( $ this -> jobs as $ job ) { if ( $ job -> canRunInBackground ( ) ) { $ background [ ] = $ job ; } else { $ foreground [ ] = $ job ; } } return array_merge ( $ background , $ foreground ) ; } | Prioritise jobs in background . |
56,733 | public function php ( $ script , $ bin = null , $ args = [ ] , $ id = null ) { if ( ! is_string ( $ script ) ) { throw new InvalidArgumentException ( 'The script should be a valid path to a file.' ) ; } $ bin = $ bin !== null && is_string ( $ bin ) && file_exists ( $ bin ) ? $ bin : ( PHP_BINARY === '' ? '/usr/bin/php'... | Queues a php script execution . |
56,734 | public function raw ( $ command , $ args = [ ] , $ id = null ) { $ job = new Job ( $ command , $ args , $ id ) ; $ this -> queueJob ( $ job -> configure ( $ this -> config ) ) ; return $ job ; } | Queue a raw shell command . |
56,735 | public function isDue ( DateTime $ date = null ) { if ( ! $ this -> executionTime ) { $ this -> at ( '* * * * *' ) ; } $ date = $ date !== null ? $ date : $ this -> creationTime ; if ( $ this -> executionYear && $ this -> executionYear !== $ date -> format ( 'Y' ) ) { return false ; } return $ this -> executionTime -> ... | Check if the Job is due to run . It accepts as input a DateTime used to check if the job is due . Defaults to job creation time . It also defaults the execution time if not previously defined . |
56,736 | public function compile ( ) { $ compiled = $ this -> command ; if ( is_callable ( $ compiled ) ) { return $ compiled ; } foreach ( $ this -> args as $ key => $ value ) { $ compiled .= ' ' . escapeshellarg ( $ key ) ; if ( $ value !== null ) { $ compiled .= ' ' . escapeshellarg ( $ value ) ; } } if ( count ( $ this -> o... | Compile the Job command . |
56,737 | private function createLockFile ( $ content = null ) { if ( $ this -> lockFile ) { if ( $ content === null || ! is_string ( $ content ) ) { $ content = $ this -> getId ( ) ; } file_put_contents ( $ this -> lockFile , $ content ) ; } } | Create the job lock file . |
56,738 | public function email ( $ email ) { if ( ! is_string ( $ email ) && ! is_array ( $ email ) ) { throw new InvalidArgumentException ( 'The email can be only string or array' ) ; } $ this -> emailTo = is_array ( $ email ) ? $ email : [ $ email ] ; $ this -> inForeground ( ) ; return $ this ; } | Set the emails where the output should be sent to . The Job should be set to write output to a file for this to work . |
56,739 | private function finalise ( ) { $ this -> emailOutput ( ) ; if ( is_callable ( $ this -> after ) ) { call_user_func ( $ this -> after , $ this -> output , $ this -> returnCode ) ; } } | Finilise the job after execution . |
56,740 | public function getEmailConfig ( ) { if ( ! isset ( $ this -> emailConfig [ 'subject' ] ) || ! is_string ( $ this -> emailConfig [ 'subject' ] ) ) { $ this -> emailConfig [ 'subject' ] = 'Cronjob execution' ; } if ( ! isset ( $ this -> emailConfig [ 'from' ] ) ) { $ this -> emailConfig [ 'from' ] = [ 'cronjob@server.my... | Get email configuration . |
56,741 | private function sendToEmails ( array $ files ) { $ config = $ this -> getEmailConfig ( ) ; $ mailer = new \ Swift_Mailer ( $ config [ 'transport' ] ) ; $ message = ( new \ Swift_Message ( ) ) -> setSubject ( $ config [ 'subject' ] ) -> setFrom ( $ config [ 'from' ] ) -> setTo ( $ this -> emailTo ) -> setBody ( $ confi... | Send files to emails . |
56,742 | public function date ( $ date ) { if ( ! $ date instanceof DateTime ) { $ date = new DateTime ( $ date ) ; } $ this -> executionYear = $ date -> format ( 'Y' ) ; return $ this -> at ( "{$date->format('i')} {$date->format('H')} {$date->format('d')} {$date->format('m')} *" ) ; } | Run the Job at a specific date . |
56,743 | public function daily ( $ hour = 0 , $ minute = 0 ) { if ( is_string ( $ hour ) ) { $ parts = explode ( ':' , $ hour ) ; $ hour = $ parts [ 0 ] ; $ minute = isset ( $ parts [ 1 ] ) ? $ parts [ 1 ] : '0' ; } $ c = $ this -> validateCronSequence ( $ minute , $ hour ) ; return $ this -> at ( "{$c['minute']} {$c['hour']} *... | Set the execution time to once a day . |
56,744 | public function weekly ( $ weekday = 0 , $ hour = 0 , $ minute = 0 ) { if ( is_string ( $ hour ) ) { $ parts = explode ( ':' , $ hour ) ; $ hour = $ parts [ 0 ] ; $ minute = isset ( $ parts [ 1 ] ) ? $ parts [ 1 ] : '0' ; } $ c = $ this -> validateCronSequence ( $ minute , $ hour , null , null , $ weekday ) ; return $ ... | Set the execution time to once a week . |
56,745 | public function mergeApplicationDefinition ( $ mergeArgs = true ) { $ appDefinition = $ this -> getApplication ( ) -> getDefinition ( ) ; $ originalOptions = $ appDefinition -> getOptions ( ) ; $ appDefinition -> setOptions ( $ this -> filterApplicationOptions ( $ originalOptions ) ) ; parent :: mergeApplicationDefinit... | Ignore user - defined global options |
56,746 | protected function escapeForShell ( $ result , $ shellType ) { switch ( $ shellType ) { case 'bash' : $ context = $ this -> handler -> getContext ( ) ; $ wordStart = substr ( $ context -> getRawCurrentWord ( ) , 0 , 1 ) ; if ( $ wordStart == "'" ) { $ result = str_replace ( "'" , "\\'" , $ result ) ; } else if ( $ word... | Escape each completion result for the specified shell |
56,747 | public function runCompletion ( ) { if ( ! $ this -> context ) { throw new \ RuntimeException ( 'A CompletionContext must be set before requesting completion.' ) ; } $ cmdName = $ this -> getInput ( ) -> getFirstArgument ( ) ; try { $ this -> command = $ this -> application -> find ( $ cmdName ) ; } catch ( \ InvalidAr... | Do the actual completion returning an array of strings to provide to the parent shell s completion system |
56,748 | public function getInput ( ) { $ words = $ this -> context -> getWords ( ) ; array_shift ( $ words ) ; $ words = array_filter ( $ words ) ; return new ArrayInput ( $ words ) ; } | Get an InputInterface representation of the completion context |
56,749 | protected function completeForOptionShortcuts ( ) { $ word = $ this -> context -> getCurrentWord ( ) ; if ( strpos ( $ word , '-' ) === 0 && strlen ( $ word ) == 2 ) { $ definition = $ this -> command ? $ this -> command -> getNativeDefinition ( ) : $ this -> application -> getDefinition ( ) ; if ( $ definition -> hasS... | Attempt to complete the current word as an option shortcut . |
56,750 | protected function completeForOptionShortcutValues ( ) { $ wordIndex = $ this -> context -> getWordIndex ( ) ; if ( $ this -> command && $ wordIndex > 1 ) { $ left = $ this -> context -> getWordAtIndex ( $ wordIndex - 1 ) ; if ( $ left [ 0 ] == '-' && strlen ( $ left ) == 2 ) { $ shortcut = substr ( $ left , 1 ) ; $ de... | Attempt to complete the current word as the value of an option shortcut |
56,751 | protected function completeForOptionValues ( ) { $ wordIndex = $ this -> context -> getWordIndex ( ) ; if ( $ this -> command && $ wordIndex > 1 ) { $ left = $ this -> context -> getWordAtIndex ( $ wordIndex - 1 ) ; if ( strpos ( $ left , '--' ) === 0 ) { $ name = substr ( $ left , 2 ) ; $ def = $ this -> command -> ge... | Attemp to complete the current word as the value of a long - form option |
56,752 | protected function completeForCommandName ( ) { if ( ! $ this -> command || ( count ( $ this -> context -> getWords ( ) ) == 2 && $ this -> context -> getWordIndex ( ) == 1 ) ) { return $ this -> getCommandNames ( ) ; } return false ; } | Attempt to complete the current word as a command name |
56,753 | protected function completeForCommandArguments ( ) { if ( ! $ this -> command || strpos ( $ this -> context -> getCurrentWord ( ) , '-' ) === 0 ) { return false ; } $ definition = $ this -> command -> getNativeDefinition ( ) ; $ argWords = $ this -> mapArgumentsToWords ( $ definition -> getArguments ( ) ) ; $ wordIndex... | Attempt to complete the current word as a command argument value |
56,754 | protected function getCompletionHelper ( $ name , $ type ) { foreach ( $ this -> helpers as $ helper ) { if ( $ helper -> getType ( ) != $ type && $ helper -> getType ( ) != CompletionInterface :: ALL_TYPES ) { continue ; } if ( $ helper -> getCommandName ( ) == CompletionInterface :: ALL_COMMANDS || $ helper -> getCom... | Find a CompletionInterface that matches the current command target name and target type |
56,755 | protected function completeOption ( InputOption $ option ) { if ( $ helper = $ this -> getCompletionHelper ( $ option -> getName ( ) , Completion :: TYPE_OPTION ) ) { return $ helper -> run ( ) ; } if ( $ this -> command instanceof CompletionAwareInterface ) { return $ this -> command -> completeOptionValues ( $ option... | Complete the value for the given option if a value completion is availble |
56,756 | protected function mapArgumentsToWords ( $ argumentDefinitions ) { $ argumentPositions = array ( ) ; $ argumentNumber = 0 ; $ previousWord = null ; $ argumentNames = array_keys ( $ argumentDefinitions ) ; $ optionsWithArgs = $ this -> getOptionWordsWithValues ( ) ; foreach ( $ this -> context -> getWords ( ) as $ wordI... | Step through the command line to determine which word positions represent which argument values |
56,757 | protected function filterResults ( array $ array ) { $ curWord = $ this -> context -> getCurrentWord ( ) ; return array_filter ( $ array , function ( $ val ) use ( $ curWord ) { return fnmatch ( $ curWord . '*' , $ val ) ; } ) ; } | Filter out results that don t match the current word on the command line |
56,758 | protected function getAllOptions ( ) { if ( ! $ this -> command ) { return $ this -> application -> getDefinition ( ) -> getOptions ( ) ; } return array_merge ( $ this -> command -> getNativeDefinition ( ) -> getOptions ( ) , $ this -> application -> getDefinition ( ) -> getOptions ( ) ) ; } | Get the combined options of the application and entered command |
56,759 | protected function getCommandNames ( ) { if ( method_exists ( '\Symfony\Component\Console\Command\Command' , 'isHidden' ) ) { $ commands = array ( ) ; foreach ( $ this -> application -> all ( ) as $ name => $ command ) { if ( ! $ command -> isHidden ( ) ) { $ commands [ ] = $ name ; } } return $ commands ; } else { $ c... | Get command names available for completion |
56,760 | public function generateHook ( $ type , $ programPath , $ programName = null , $ multiple = false ) { if ( ! isset ( self :: $ hooks [ $ type ] ) ) { throw new \ RuntimeException ( sprintf ( "Cannot generate hook for unknown shell type '%s'. Available hooks are: %s" , $ type , implode ( ', ' , self :: getShellTypes ( )... | Return a completion hook for the specified shell type |
56,761 | protected function generateFunctionName ( $ programPath , $ programName ) { return sprintf ( '_%s_%s_complete' , $ this -> sanitiseForFunctionName ( basename ( $ programName ) ) , substr ( md5 ( $ programPath ) , 0 , 16 ) ) ; } | Generate a function name that is unlikely to conflict with other generated function names in the same shell |
56,762 | public function run ( ) { $ model = Yii :: createObject ( $ this -> modelClass ) ; $ event = Yii :: createObject ( [ 'class' => FormEvent :: class , 'form' => $ model ] ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> validate ( ) ) { $ this -> trigger ( self :: EVENT_BEFORE_SAVE , $ event... | Renders the settings form . |
56,763 | protected function prepareModel ( Model $ model ) { if ( is_callable ( $ this -> prepareModel ) ) { call_user_func ( $ this -> prepareModel , $ model ) ; } else { foreach ( $ model -> attributes ( ) as $ attribute ) { $ value = Yii :: $ app -> settings -> get ( $ this -> getSection ( $ model ) , $ attribute ) ; if ( ! ... | Prepares the model which will be used to validate the attributes . |
56,764 | protected function findModel ( int $ id ) { $ settingModelClass = $ this -> modelClass ; if ( ( $ model = $ settingModelClass :: findOne ( $ id ) ) !== null ) { return $ model ; } else { throw new NotFoundHttpException ( Yii :: t ( 'yii2mod.settings' , 'The requested page does not exist.' ) ) ; } } | Finds a Setting model based on its primary key value . |
56,765 | public function getAllBySection ( $ section , $ default = null ) { $ items = $ this -> getSettingsConfig ( ) ; if ( isset ( $ items [ $ section ] ) ) { $ this -> setting = ArrayHelper :: getColumn ( $ items [ $ section ] , 'value' ) ; } else { $ this -> setting = $ default ; } return $ this -> setting ; } | Get s all values in the specific section . |
56,766 | public function get ( $ section , $ key , $ default = null ) { $ items = $ this -> getSettingsConfig ( ) ; if ( isset ( $ items [ $ section ] [ $ key ] ) ) { $ this -> setting = ArrayHelper :: getValue ( $ items [ $ section ] [ $ key ] , 'value' ) ; $ type = ArrayHelper :: getValue ( $ items [ $ section ] [ $ key ] , '... | Get s the value for the given section and key . |
56,767 | public function set ( $ section , $ key , $ value , $ type = null ) : bool { if ( $ this -> model -> setSetting ( $ section , $ key , $ value , $ type ) ) { if ( $ this -> invalidateCache ( ) ) { return true ; } } return false ; } | Add a new setting or update an existing one . |
56,768 | public function has ( $ section , $ key ) : bool { $ setting = $ this -> get ( $ section , $ key ) ; return ! empty ( $ setting ) ; } | Checking existence of setting |
56,769 | public function remove ( $ section , $ key ) : bool { if ( $ this -> model -> removeSetting ( $ section , $ key ) ) { if ( $ this -> invalidateCache ( ) ) { return true ; } } return false ; } | Remove setting by section and key |
56,770 | protected function getSettingsConfig ( ) : array { if ( ! $ this -> cache instanceof Cache ) { $ this -> items = $ this -> model -> getSettings ( ) ; } else { $ cacheItems = $ this -> cache -> get ( $ this -> cacheKey ) ; if ( ! empty ( $ cacheItems ) ) { $ this -> items = $ cacheItems ; } else { $ this -> items = $ th... | Returns the settings config |
56,771 | protected function convertSettingType ( $ type ) { if ( $ type === SettingType :: BOOLEAN_TYPE ) { $ this -> setting = filter_var ( $ this -> setting , FILTER_VALIDATE_BOOLEAN ) ; } else { settype ( $ this -> setting , $ type ) ; } } | Set type for setting |
56,772 | public function getSettings ( ) : array { $ result = [ ] ; $ settings = static :: find ( ) -> select ( [ 'type' , 'section' , 'key' , 'value' ] ) -> active ( ) -> asArray ( ) -> all ( ) ; foreach ( $ settings as $ setting ) { $ section = $ setting [ 'section' ] ; $ key = $ setting [ 'key' ] ; $ settingOptions = [ 'type... | Return array of settings |
56,773 | public function isApplicable ( $ relativePath ) { $ relativePathAdapted = preg_replace ( '/^\.\//' , '' , $ relativePath ) ; if ( $ this -> portableItemParser -> hasPortableElement ( ) && $ this -> portableItemParser -> isPortableElementAsset ( $ relativePathAdapted ) ) { return true ; } return false ; } | Check if given file is into pci and required by this pci |
56,774 | public function handle ( $ absolutePath , $ relativePath ) { $ relativePathAdapted = preg_replace ( '/^\.\//' , '' , $ relativePath ) ; return $ this -> portableItemParser -> importPortableElementFile ( $ absolutePath , $ relativePathAdapted ) ; } | Handle Pci asset import |
56,775 | public function importQTIFile ( $ qtiFile , core_kernel_classes_Class $ itemClass , $ validate = true ) { $ report = null ; try { $ qtiModel = $ this -> createQtiItemModel ( $ qtiFile , $ validate ) ; $ rdfItem = $ this -> createRdfItem ( $ itemClass , $ qtiModel ) ; $ report = \ common_report_Report :: createSuccess (... | Short description of method importQTIFile |
56,776 | public function importResourceMetadata ( array $ metadataValues , Resource $ qtiResource , core_kernel_classes_Resource $ resource , array $ ontologyInjectors = array ( ) ) { $ identifier = $ qtiResource -> getIdentifier ( ) ; if ( isset ( $ metadataValues [ $ identifier ] ) === true ) { \ common_Logger :: i ( "Prepari... | Import metadata to a given QTI Item . |
56,777 | protected function getMetadataImporter ( ) { if ( ! $ this -> metadataImporter ) { $ this -> metadataImporter = $ this -> getServiceLocator ( ) -> get ( MetadataService :: SERVICE_ID ) -> getImporter ( ) ; } return $ this -> metadataImporter ; } | Get the lom metadata importer |
56,778 | public function handle ( $ absolutePath , $ relativePath ) { $ safePath = $ this -> safePath ( $ relativePath ) ; $ this -> encodeStimulusImages ( $ absolutePath ) ; $ info = $ this -> getItemSource ( ) -> add ( $ absolutePath , basename ( $ absolutePath ) , $ safePath ) ; \ common_Logger :: i ( 'Stimulus file \'' . $ ... | Store locally in a safe directory Encoded all stimulus images to avoid file dependencies |
56,779 | public function getChoiceBySerial ( $ serial ) { $ returnValue = null ; $ choices = $ this -> getChoices ( ) ; if ( isset ( $ choices [ $ serial ] ) ) { $ returnValue = $ choices [ $ serial ] ; } return $ returnValue ; } | Find a choice identified by its serial |
56,780 | public function getResponse ( ) { $ returnValue = null ; $ responseAttribute = $ this -> getAttribute ( 'responseIdentifier' ) ; if ( ! is_null ( $ responseAttribute ) ) { $ idenfierBaseType = $ responseAttribute -> getValue ( true ) ; if ( ! is_null ( $ idenfierBaseType ) ) { $ returnValue = $ idenfierBaseType -> getR... | Get the response declaration associated to the interaction If no response exists one will be created |
56,781 | public function setResponse ( ResponseDeclaration $ response ) { $ relatedItem = $ this -> getRelatedItem ( ) ; if ( ! is_null ( $ relatedItem ) ) { $ relatedItem -> addResponse ( $ response ) ; } return $ this -> setAttribute ( 'responseIdentifier' , $ response ) ; } | Define the interaction s response |
56,782 | public function getIdentifier ( $ generate = true ) { if ( empty ( $ this -> identifier ) && $ generate ) { $ relatedItem = $ this -> getRelatedItem ( ) ; if ( ! is_null ( $ relatedItem ) ) { $ this -> identifier = $ this -> generateIdentifier ( ) ; } } return ( string ) $ this -> identifier ; } | get the identifier |
56,783 | public function setIdentifier ( $ identifier , $ collisionFree = false ) { $ returnValue = false ; if ( empty ( $ identifier ) || is_null ( $ identifier ) ) { common_Logger :: w ( 'ss' ) ; throw new \ InvalidArgumentException ( "Id must not be empty" ) ; } if ( $ this -> isIdentifierAvailable ( $ identifier ) ) { $ ret... | Set a unique identifier . If the identifier is already given to another qti element in the same item an InvalidArgumentException is thrown . The option collisionFree allows to ensure that a new identifier is generated if a collision happens |
56,784 | public function validateCurrentIdentifier ( $ collisionFree = false ) { $ returnValue = false ; if ( empty ( $ this -> identifier ) ) { $ returnValue = true ; } else { $ returnValue = $ this -> setIdentifier ( $ this -> identifier , $ collisionFree ) ; } return $ returnValue ; } | Validate if the current identifier of the qti element does not collide with another one s CollisionFree option allows to ensure that no collision subsides after the fonction call . It indeed ensures that that the identifier becomes unique if it collides with another one s . |
56,785 | protected function generateIdentifier ( $ prefix = '' ) { $ relatedItem = $ this -> getRelatedItem ( ) ; if ( is_null ( $ relatedItem ) ) { throw new QtiModelException ( 'cannot generate the identifier because the element does not belong to any item' ) ; } $ identifiedElementsCollection = $ relatedItem -> getIdentified... | Create a unique identifier based on the class if the qti element . |
56,786 | public function extract ( ) { foreach ( $ this -> item -> getComposingElements ( ) as $ element ) { $ this -> extractImg ( $ element ) ; $ this -> extractObject ( $ element ) ; $ this -> extractStyleSheet ( $ element ) ; $ this -> extractCustomElement ( $ element ) ; if ( $ this -> getGetXinclude ( ) ) { $ this -> extr... | Extract all assets from the current item |
56,787 | private function extractObject ( Element $ element ) { if ( $ element instanceof Container ) { foreach ( $ element -> getElements ( 'oat\taoQtiItem\model\qti\QtiObject' ) as $ object ) { $ this -> loadObjectAssets ( $ object ) ; } } if ( $ element instanceof QtiObject ) { $ this -> loadObjectAssets ( $ element ) ; } } | Lookup and extract assets from a QTI Object |
56,788 | private function extractStyleSheet ( Element $ element ) { if ( $ element instanceof StyleSheet ) { $ href = $ element -> attr ( 'href' ) ; $ this -> addAsset ( 'css' , $ href ) ; $ parsedUrl = parse_url ( $ href ) ; if ( $ this -> isDeepParsing ( ) && array_key_exists ( 'path' , $ parsedUrl ) && ! array_key_exists ( '... | Lookup and extract assets from a stylesheet element |
56,789 | private function loadObjectAssets ( QtiObject $ object ) { $ type = $ object -> attr ( 'type' ) ; if ( strpos ( $ type , "image" ) !== false ) { $ this -> addAsset ( 'img' , $ object -> attr ( 'data' ) ) ; } else if ( strpos ( $ type , "video" ) !== false || strpos ( $ type , "ogg" ) !== false ) { $ this -> addAsset ( ... | Loads assets from an QTI object element |
56,790 | private function addAsset ( $ type , $ uri ) { if ( ! array_key_exists ( $ type , $ this -> assets ) ) { $ this -> assets [ $ type ] = array ( ) ; } if ( ! empty ( $ uri ) && ! in_array ( $ uri , $ this -> assets [ $ type ] ) ) { $ this -> assets [ $ type ] [ ] = $ uri ; } } | Add the asset to the current list |
56,791 | private function loadStyleSheetAsset ( $ css ) { $ imageRe = "/url\\s*\\(['|\"]?([^)]*\.(png|jpg|jpeg|gif|svg))['|\"]?\\)/mi" ; $ importRe = "/@import\\s*(url\\s*\\()?['\"]?([^;]*)['\"]/mi" ; $ fontFaceRe = "/@font-face\\s*\\{(.*)?\\}/mi" ; $ fontRe = "/url\\s*\\(['|\"]?([^)'|\"]*)['|\"]?\\)/i" ; preg_match_all ( $ ima... | Parse extract and load assets from the stylesheet content |
56,792 | static public function getEntryPath ( ) { return [ LomMetadata :: LOM_NAMESPACE . '#lom' , LomMetadata :: LOM_NAMESPACE . '#classification' , LomMetadata :: LOM_NAMESPACE . '#taxonPath' , LomMetadata :: LOM_NAMESPACE . '#taxon' , LomMetadata :: LOM_NAMESPACE . '#entry' , LomMetadata :: LOM_NAMESPACE . '#string' ] ; } | Get default entry path into DomDocument |
56,793 | public function getDataItemByRdfItem ( core_kernel_classes_Resource $ item , $ langCode = '' , $ resolveXInclude = false ) { $ returnValue = null ; try { $ file = $ this -> getXmlByRdfItem ( $ item , $ langCode ) ; $ qtiParser = new Parser ( $ file ) ; $ returnValue = $ qtiParser -> load ( ) ; if ( is_null ( $ returnVa... | Load a QTI_Item from an RDF Item using the itemContent property of the Item as the QTI xml |
56,794 | public function getXmlByRdfItem ( core_kernel_classes_Resource $ item , $ language = '' ) { $ itemService = taoItems_models_classes_ItemsService :: singleton ( ) ; if ( ! $ itemService -> hasItemModel ( $ item , array ( ItemModel :: MODEL_URI ) ) ) { throw new common_Exception ( 'Non QTI item(' . $ item -> getUri ( ) .... | Load the XML of the QTI item |
56,795 | public function saveDataItemToRdfItem ( Item $ qtiItem , core_kernel_classes_Resource $ rdfItem ) { $ label = mb_substr ( $ rdfItem -> getLabel ( ) , 0 , 256 , 'UTF-8' ) ; if ( $ qtiItem -> hasAttribute ( 'xml:lang' ) && ! empty ( $ qtiItem -> getAttributeValue ( 'xml:lang' ) ) ) { $ lang = $ qtiItem -> getAttributeVal... | Save a QTI_Item into an RDF Item by exporting the QTI_Item to QTI xml and saving it in the itemContent property of the RDF Item |
56,796 | public function loadItemFromFile ( $ file ) { $ returnValue = null ; if ( is_string ( $ file ) && ! empty ( $ file ) ) { try { $ qtiParser = new Parser ( $ file ) ; $ qtiParser -> validate ( ) ; if ( ! $ qtiParser -> isValid ( ) ) { throw new ParsingException ( $ qtiParser -> displayErrors ( ) ) ; } $ returnValue = $ q... | Load a QTI item from a qti file in parameter . |
56,797 | public function getStatus ( ) { try { if ( ! $ this -> hasRequestParameter ( self :: TASK_ID_PARAM ) ) { throw new \ common_exception_MissingParameter ( self :: TASK_ID_PARAM , $ this -> getRequestURI ( ) ) ; } $ data = $ this -> getTaskLogReturnData ( $ this -> getRequestParameter ( self :: TASK_ID_PARAM ) , $ this ->... | Action to retrieve test import status from queue |
56,798 | protected function getTaskStatus ( EntityInterface $ taskLogEntity ) { if ( $ taskLogEntity -> getStatus ( ) -> isCreated ( ) ) { return __ ( 'In Progress' ) ; } else if ( $ taskLogEntity -> getStatus ( ) -> isCompleted ( ) ) { return __ ( 'Success' ) ; } return $ taskLogEntity -> getStatus ( ) -> getLabel ( ) ; } | Return Success instead of Completed required by the specified API . |
56,799 | public function getTemplateContent ( ) { $ standardRpTemplateFolder = dirname ( __FILE__ ) . '/../data/qtiv2p1/rptemplates/' ; switch ( $ this -> uri ) { case self :: MATCH_CORRECT : $ returnValue = file_get_contents ( $ standardRpTemplateFolder . 'match_correct.xml' ) ; break ; case self :: MAP_RESPONSE : $ returnValu... | Get the content of the response processing template identified by its uri |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.