idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
49,800 | protected function paginate ( $ collection , $ options = array ( ) , $ dataRenderer = null ) { return ( new Paginator ( ) ) -> paginate ( $ collection , $ options , $ dataRenderer ) ; } | Wrap a datatable action to paginator to have subset of data |
49,801 | protected function getStorage ( ) { if ( ! $ this -> storage ) { $ storage = $ this -> getServiceLocator ( ) -> get ( Storage :: SERVICE_ID ) ; if ( ! $ storage instanceof PaginatedStorage ) { throw new StorageException ( __ ( 'The storage service provided to store the diagnostic results must be upgraded to support rea... | Get diangostic storage |
49,802 | public function login ( ) { try { if ( ! $ this -> hasRequestParameter ( 'successCallback' ) ) { throw new \ common_exception_MissingParameter ( 'Internal error, please retry in few moment' ) ; } if ( $ this -> isRequestPost ( ) ) { $ authorizationService = $ this -> getServiceLocator ( ) -> get ( Authorization :: SERV... | Login process Check if url successCallback is set If login form is post valid setcookie & redirect to successCallback Else create LoginForm with ?errorMessage |
49,803 | protected function getData ( $ check = false ) { $ data = parent :: getData ( $ check ) ; $ data [ 'login' ] = UserHelper :: getUserLogin ( \ common_session_SessionManager :: getSession ( ) -> getUser ( ) ) ; if ( $ this -> hasRequestParameter ( 'workstation' ) ) { $ data [ PaginatedSqlStorage :: DIAGNOSTIC_WORKSTATION... | Fetch POST data Get login by cookie If check parameters is true check mandatory parameters |
49,804 | public function workstation ( ) { $ response = [ 'success' => false , 'workstation' => uniqid ( 'workstation-' ) ] ; $ diagnostic = $ this -> getDiagnosticDataTable ( ) -> getDiagnostic ( $ this -> getId ( ) ) ; if ( isset ( $ diagnostic ) ) { $ response [ 'success' ] = true ; $ workstation = trim ( $ diagnostic [ Pagi... | Gets the name of the workstation being tested If current id is found on database associated workstation is retrieve Else an uniqid is generated |
49,805 | public function recordThat ( Message $ event ) : void { if ( ! \ array_key_exists ( $ event -> messageName ( ) , $ this -> eventApplyMap ) ) { throw new \ RuntimeException ( 'Wrong event recording detected. Unknown event passed to GenericAggregateRoot: ' . $ event -> messageName ( ) ) ; } $ this -> version += 1 ; $ eve... | Record an aggregate changed event |
49,806 | public function upsertDoc ( string $ collectionName , string $ docId , array $ docOrSubset ) : void { if ( $ this -> hasDoc ( $ collectionName , $ docId ) ) { $ this -> updateDoc ( $ collectionName , $ docId , $ docOrSubset ) ; } else { $ this -> addDoc ( $ collectionName , $ docId , $ docOrSubset ) ; } } | Same as updateDoc except that doc is added to collection if it does not exist . |
49,807 | public function getQueueByWeight ( ) { $ weights = array_map ( function ( QueueInterface $ queue ) { return $ queue -> getWeight ( ) ; } , $ this -> getQueues ( ) ) ; $ rand = mt_rand ( 1 , array_sum ( $ weights ) ) ; foreach ( $ this -> getQueues ( ) as $ queue ) { $ rand -= $ queue -> getWeight ( ) ; if ( $ rand <= 0... | Gets random queue based on weight . |
49,808 | protected function runWorker ( QueueInterface $ queue ) { ( new Worker ( $ this , $ this -> getTaskLog ( ) , false ) ) -> setDedicatedQueue ( $ queue , 1 ) -> run ( ) ; } | Run worker on - the - fly for one round . |
49,809 | public function getTaskResource ( \ core_kernel_classes_Resource $ resource ) { $ tasksRootClass = $ this -> getClass ( Task :: TASK_CLASS ) ; $ taskResources = $ tasksRootClass -> searchInstances ( [ Task :: PROPERTY_LINKED_RESOURCE => $ resource -> getUri ( ) ] ) ; return empty ( $ taskResources ) ? null : current ( ... | Get resource from rdf storage which represents task in the task queue by linked resource Returns null if there is no task linked to given resource |
49,810 | public function getReportByLinkedResource ( \ core_kernel_classes_Resource $ resource ) { $ taskResource = $ this -> getTaskResource ( $ resource ) ; if ( $ taskResource !== null ) { $ report = $ taskResource -> getOnePropertyValue ( $ this -> getProperty ( Task :: PROPERTY_REPORT ) ) ; if ( $ report ) { $ report = Rep... | It will be deprecated once we have the general GUI for displaying different info of a task for the user . |
49,811 | private function pickQueueByWight ( array $ queues ) { $ weights = array_map ( function ( QueueInterface $ queue ) { return $ queue -> getWeight ( ) ; } , $ queues ) ; $ rand = mt_rand ( 1 , array_sum ( $ weights ) ) ; foreach ( $ queues as $ queue ) { $ rand -= $ queue -> getWeight ( ) ; if ( $ rand <= 0 ) { return $ ... | Picks randomly a queue based on weight . |
49,812 | public function initResultServer ( $ compiledDelivery , $ executionIdentifier , $ userUri ) { $ storage = $ this -> getResultStorage ( $ compiledDelivery ) ; $ storage -> storeRelatedTestTaker ( $ executionIdentifier , $ userUri ) ; $ storage -> storeRelatedDelivery ( $ executionIdentifier , $ compiledDelivery -> getUr... | Starts or resume a taoResultServerStateFull session for results submission |
49,813 | protected function getQtiResultService ( ) { if ( ! $ this -> service ) { $ this -> service = $ this -> getServiceManager ( ) -> get ( ResultService :: SERVICE_ID ) ; } return $ this -> service ; } | Return the service for Result |
49,814 | public function byDeliveryExecution ( ) { try { $ this -> checkMethod ( ) ; $ this -> validateParams ( array ( self :: DELIVERY_EXECUTION ) ) ; $ deliveryExecution = $ this -> getQtiResultService ( ) -> getDeliveryExecutionById ( $ this -> getRequestParameter ( self :: DELIVERY_EXECUTION ) ) ; $ this -> returnValidXml ... | It requires only Delivery Execution in URI format . |
49,815 | protected function validateParams ( array $ params ) { foreach ( $ params as $ param ) { if ( ! $ this -> hasRequestParameter ( $ param ) ) { throw new common_exception_MissingParameter ( $ param . ' is missing from the request.' , $ this -> getRequestURI ( ) ) ; } if ( empty ( $ this -> getRequestParameter ( $ param )... | Validates the given parameters . |
49,816 | protected function returnValidXml ( $ data ) { if ( empty ( $ data ) ) { throw new common_exception_NotFound ( 'Delivery execution not found.' ) ; } $ doc = @ simplexml_load_string ( $ data ) ; if ( ! $ doc ) { common_Logger :: i ( 'invalid xml result' ) ; throw new Exception ( 'Xml output is malformed.' ) ; } header (... | Return XML response if it is valid . |
49,817 | public function spawnResult ( ) { $ result = null ; foreach ( $ this -> getAllImplementations ( StorageWrite :: class ) as $ impl ) { $ result = $ impl -> spawnResult ( ) ; } return $ result ; } | Not sure how multiple engines are supposed to handle this |
49,818 | protected function getDeliveryExecutionService ( ) { if ( ! $ this -> deliveryExecutionService ) { $ this -> deliveryExecutionService = $ this -> getServiceLocator ( ) -> get ( ServiceProxy :: SERVICE_ID ) ; } return $ this -> deliveryExecutionService ; } | Get the implementation of delivery execution service |
49,819 | public function getDeliveryExecutionById ( $ deliveryExecutionId ) { $ deliveryExecution = $ this -> getDeliveryExecutionService ( ) -> getDeliveryExecution ( $ deliveryExecutionId ) ; try { $ deliveryExecution -> getDelivery ( ) ; } catch ( \ common_exception_NotFound $ e ) { throw new \ common_exception_NotFound ( 'P... | Get Delivery execution from resource |
49,820 | public function getDeliveryExecutionXml ( DeliveryExecutionInterface $ deliveryExecution ) { return $ this -> getQtiResultXml ( $ deliveryExecution -> getDelivery ( ) -> getUri ( ) , $ deliveryExecution -> getIdentifier ( ) ) ; } | Return delivery execution as xml of testtaker based on delivery |
49,821 | public function push ( TaskInterface $ task ) { return ( bool ) $ this -> getPersistence ( ) -> insert ( $ this -> getTableName ( ) , [ 'message' => $ this -> serializeTask ( $ task ) , 'created_at' => $ this -> getPersistence ( ) -> getPlatForm ( ) -> getNowExpression ( ) ] ) ; } | Insert a new task into the queue table . |
49,822 | protected function doPop ( ) { $ this -> getPersistence ( ) -> getPlatform ( ) -> beginTransaction ( ) ; $ logContext = [ 'Queue' => $ this -> getQueueNameWithPrefix ( ) ] ; try { $ qb = $ this -> getQueryBuilder ( ) -> select ( 'id, message' ) -> from ( $ this -> getTableName ( ) ) -> andWhere ( 'visible = :visible' )... | Does the DBAL specific pop mechanism . |
49,823 | public function delete ( TaskInterface $ task ) { $ this -> doDelete ( $ task -> getMetadata ( 'RdsMessageId' ) , [ 'InternalMessageId' => $ task -> getId ( ) , 'RdsMessageId' => $ task -> getMetadata ( 'RdsMessageId' ) ] ) ; } | Delete the message after being processed by the worker . |
49,824 | public function get ( ) { try { $ this -> returnSuccess ( $ this -> getTaskEntity ( ) -> toArray ( ) ) ; } catch ( \ Exception $ e ) { $ this -> returnFailure ( $ e ) ; } } | Returns the details of a task independently from the owner . |
49,825 | public function addAvailableFilters ( $ userId ) { $ this -> neq ( TaskLogBrokerInterface :: COLUMN_STATUS , TaskLogInterface :: STATUS_ARCHIVED ) ; if ( $ userId !== TaskLogInterface :: SUPER_USER ) { $ this -> eq ( TaskLogBrokerInterface :: COLUMN_OWNER , $ userId ) ; } return $ this ; } | Add a basic filter to query only rows belonging to a given user and not having status ARCHIVED . |
49,826 | public function createQueue ( ) { try { $ result = $ this -> getClient ( ) -> createQueue ( [ 'QueueName' => $ this -> getQueueNameWithPrefix ( ) , 'Attributes' => [ 'DelaySeconds' => 0 , 'VisibilityTimeout' => 600 ] ] ) ; if ( $ result -> hasKey ( 'QueueUrl' ) ) { $ this -> queueUrl = $ result -> get ( 'QueueUrl' ) ; ... | Creates queue . |
49,827 | protected function doPop ( ) { if ( ! $ this -> queueExists ( ) ) { $ this -> createQueue ( ) ; } $ logContext = [ 'QueueUrl' => $ this -> queueUrl ] ; try { $ result = $ this -> getClient ( ) -> receiveMessage ( [ 'AttributeNames' => [ ] , 'MaxNumberOfMessages' => $ this -> getNumberOfTasksToReceive ( ) , 'MessageAttr... | Does the SQS specific pop mechanism . |
49,828 | protected function doDelete ( $ receipt , array $ logContext = [ ] ) { if ( ! $ this -> queueExists ( ) ) { $ this -> createQueue ( ) ; } $ logContext = array_merge ( [ 'QueueUrl' => $ this -> queueUrl ] , $ logContext ) ; try { $ this -> getClient ( ) -> deleteMessage ( [ 'QueueUrl' => $ this -> queueUrl , 'ReceiptHan... | Delete a task by its receipt . |
49,829 | protected function queueExists ( ) { if ( isset ( $ this -> queueUrl ) ) { return true ; } if ( $ this -> getCache ( ) -> has ( $ this -> getUrlCacheKey ( ) ) ) { $ this -> queueUrl = $ this -> getCache ( ) -> get ( $ this -> getUrlCacheKey ( ) ) ; return true ; } try { $ result = $ this -> getClient ( ) -> getQueueUrl... | Checks if queue exists |
49,830 | public function getVariable ( $ callId , $ variableIdentifier ) { $ rawVariable = $ this -> getDbStorage ( ) -> getVariable ( $ callId , $ variableIdentifier ) ; if ( $ this -> canFileBeRestored ( $ rawVariable [ 0 ] -> variable ) ) { $ rawVariable [ 0 ] -> variable = $ this -> restoreFile ( $ rawVariable [ 0 ] -> vari... | Get The variable that match params |
49,831 | public function storeItemVariable ( $ deliveryResultIdentifier , $ test , $ item , taoResultServer_models_classes_Variable $ itemVariable , $ callIdItem ) { $ variable = $ this -> handleFiles ( $ deliveryResultIdentifier , $ itemVariable ) ; $ this -> getDbStorage ( ) -> storeItemVariable ( $ deliveryResultIdentifier ,... | Store Item Variable |
49,832 | public function getDefaultResultServer ( ) { $ ext = common_ext_ExtensionsManager :: singleton ( ) -> getExtensionById ( 'taoResultServer' ) ; if ( $ ext -> hasConfig ( self :: DEFAULT_RESULTSERVER_KEY ) ) { $ uri = $ ext -> getConfig ( self :: DEFAULT_RESULTSERVER_KEY ) ; } else { $ uri = ResultServerService :: INSTAN... | Return the default result server to use |
49,833 | public function setDefaultResultServer ( core_kernel_classes_Resource $ resultServer ) { $ ext = common_ext_ExtensionsManager :: singleton ( ) -> getExtensionById ( 'taoResultServer' ) ; $ ext -> setConfig ( self :: DEFAULT_RESULTSERVER_KEY , $ resultServer -> getUri ( ) ) ; } | Sets the default result server to use |
49,834 | protected function getLocalizedRedirect ( $ locale ) { return is_string ( $ localizedUrl = $ this -> localization -> getLocalizedURL ( $ locale ) ) ? $ this -> makeRedirectResponse ( $ localizedUrl ) : null ; } | Get the redirection response . |
49,835 | public function direction ( ) { if ( empty ( $ this -> direction ) ) { $ rtlScripts = [ 'Arab' , 'Hebr' , 'Mong' , 'Tfng' , 'Thaa' ] ; $ this -> setDirection ( in_array ( $ this -> script , $ rtlScripts ) ? self :: DIRECTION_RIGHT_TO_LEFT : self :: DIRECTION_LEFT_TO_RIGHT ) ; } return $ this -> direction ; } | Get locale direction . |
49,836 | public function toArray ( ) { return [ 'key' => $ this -> key ( ) , 'name' => $ this -> name ( ) , 'script' => $ this -> script ( ) , 'dir' => $ this -> direction ( ) , 'native' => $ this -> native ( ) , 'regional' => $ this -> regional ( ) , ] ; } | Get the locale entity as an array . |
49,837 | public function createUrlFromUri ( $ uri ) { $ uri = ltrim ( $ uri , '/' ) ; return empty ( $ this -> baseUrl ) ? $ this -> app [ \ Illuminate \ Contracts \ Routing \ UrlGenerator :: class ] -> to ( $ uri ) : $ this -> baseUrl . $ uri ; } | Create an url from the uri . |
49,838 | public function localesNavbar ( ) { $ view = $ this -> app [ ViewFactoryContract :: class ] ; return $ view -> make ( 'localization::navbar' , [ 'supportedLocales' => $ this -> getSupportedLocales ( ) ] ) -> render ( ) ; } | Get locales navigation bar . |
49,839 | private function findTranslatedRouteByUrl ( $ url , $ attributes , $ locale ) { if ( empty ( $ url ) ) return false ; foreach ( $ this -> routeTranslator -> getTranslatedRoutes ( ) as $ translatedRoute ) { $ translatedUrl = $ this -> getUrlFromRouteName ( $ locale , $ translatedRoute , $ attributes ) ; if ( $ this -> g... | Returns the translated route for an url and the attributes given and a locale |
49,840 | public function getUrlFromRouteName ( $ locale , $ transKey , array $ attributes = [ ] , $ showHiddenLocale = false ) { $ this -> isLocaleSupportedOrFail ( $ locale ) ; $ route = $ this -> routeTranslator -> getUrlFromRouteName ( $ locale , $ this -> getDefaultLocale ( ) , $ transKey , $ attributes , $ this -> isDefaul... | Returns an URL adapted to the route name and the locale given . |
49,841 | public function setRouteNameFromRequest ( Request $ request ) { $ routeName = $ this -> routeTranslator -> getRouteNameFromPath ( $ request -> getUri ( ) , $ this -> getCurrentLocale ( ) ) ; $ this -> routeTranslator -> setCurrentRoute ( $ routeName ) ; } | Set route name from request . |
49,842 | public function negotiate ( Request $ request ) { $ this -> request = $ request ; if ( ! is_null ( $ locale = $ this -> getFromAcceptedLanguagesHeader ( ) ) ) return $ locale ; if ( ! is_null ( $ locale = $ this -> getFromHttpAcceptedLanguagesServer ( ) ) ) return $ locale ; if ( ! is_null ( $ locale = $ this -> getFro... | Negotiate the request . |
49,843 | private function getFromAcceptedLanguagesHeader ( ) { $ matches = $ this -> getMatchesFromAcceptedLanguages ( ) ; if ( $ locale = $ this -> inSupportedLocales ( $ matches ) ) { return $ locale ; } if ( isset ( $ matches [ '*' ] ) ) { return $ this -> supportedLocales -> first ( ) -> key ( ) ; } return null ; } | Get locale from accepted languages header . |
49,844 | private function getFromHttpAcceptedLanguagesServer ( ) { $ httpAcceptLanguage = $ this -> request -> server ( 'HTTP_ACCEPT_LANGUAGE' ) ; if ( ! class_exists ( 'Locale' ) || empty ( $ httpAcceptLanguage ) ) return null ; $ locale = Locale :: acceptFromHttp ( $ httpAcceptLanguage ) ; if ( $ this -> isSupported ( $ local... | Get locale from http accepted languages server . |
49,845 | private function getFromRemoteHostServer ( ) { if ( empty ( $ remoteHost = $ this -> request -> server ( 'REMOTE_HOST' ) ) ) return null ; $ remoteHost = explode ( '.' , $ remoteHost ) ; $ locale = strtolower ( end ( $ remoteHost ) ) ; return $ this -> isSupported ( $ locale ) ? $ locale : null ; } | Get locale from remote host server . |
49,846 | private function inSupportedLocales ( array $ matches ) { foreach ( array_keys ( $ matches ) as $ locale ) { if ( $ this -> isSupported ( $ locale ) ) return $ locale ; foreach ( $ this -> supportedLocales as $ key => $ entity ) { if ( $ entity -> regional ( ) == $ locale ) return $ key ; } } return null ; } | Check if matches a supported locale . |
49,847 | private function getMatchesFromAcceptedLanguages ( ) { $ matches = [ ] ; $ acceptLanguages = $ this -> request -> header ( 'Accept-Language' ) ; if ( ! empty ( $ acceptLanguages ) ) { $ acceptLanguages = explode ( ',' , $ acceptLanguages ) ; $ genericMatches = $ this -> retrieveGenericMatches ( $ acceptLanguages , $ ma... | Return all the accepted languages from the browser |
49,848 | private function retrieveGenericMatches ( $ acceptLanguages , & $ matches ) { $ genericMatches = [ ] ; foreach ( $ acceptLanguages as $ option ) { $ option = array_map ( 'trim' , explode ( ';' , $ option ) ) ; $ locale = $ option [ 0 ] ; $ quality = $ this -> getQualityFactor ( $ locale , $ option ) ; $ quality = isset... | Get the generic matches . |
49,849 | private function getQualityFactor ( $ locale , $ option ) { if ( isset ( $ option [ 1 ] ) ) return ( float ) str_replace ( 'q=' , '' , $ option [ 1 ] ) ; if ( $ locale === '*/*' ) return 0.01 ; if ( substr ( $ locale , - 1 ) === '*' ) return 0.02 ; return null ; } | Get the quality factor . |
49,850 | public function getTranslatedRoute ( $ baseUrl , & $ parsedUrl , $ defaultLocale , LocaleCollection $ supportedLocales ) { if ( empty ( $ parsedUrl ) || ! isset ( $ parsedUrl [ 'path' ] ) ) { $ parsedUrl [ 'path' ] = '' ; } else { $ path = $ parsedUrl [ 'path' ] = str_replace ( $ baseUrl , '' , '/' . ltrim ( $ parsedUr... | Get the translated route . |
49,851 | public function getRouteNameFromPath ( $ uri , $ locale ) { $ attributes = Url :: extractAttributes ( $ uri ) ; $ uri = str_replace ( [ url ( '/' ) , "/$locale/" ] , '' , $ uri ) ; $ uri = trim ( $ uri , '/' ) ; foreach ( $ this -> translatedRoutes as $ routeName ) { $ url = Url :: substituteAttributes ( $ attributes ,... | Returns the translation key for a given path . |
49,852 | public function findTranslatedRouteByPath ( $ path , $ locale ) { foreach ( $ this -> translatedRoutes as $ route ) { if ( $ this -> translate ( $ route , $ locale ) == rawurldecode ( $ path ) ) return $ route ; } return false ; } | Returns the translated route for the path and the url given . |
49,853 | public function getUrlFromRouteName ( $ locale , $ defaultLocale , $ transKey , $ attributes = [ ] , $ defaultHidden = false , $ showHiddenLocale = false ) { if ( ! is_string ( $ locale ) ) $ locale = $ defaultLocale ; $ url = '' ; if ( ! ( $ locale === $ defaultLocale && $ defaultHidden ) || $ showHiddenLocale ) $ url... | Get URL from route name . |
49,854 | public static function extractAttributes ( $ url = false ) { $ parse = parse_url ( $ url ) ; $ path = isset ( $ parse [ 'path' ] ) ? explode ( '/' , $ parse [ 'path' ] ) : [ ] ; $ url = [ ] ; foreach ( $ path as $ segment ) { if ( ! empty ( $ segment ) ) $ url [ ] = $ segment ; } $ router = app ( 'router' ) ; return se... | Extract attributes for current url . |
49,855 | private static function extractAttributesFromRoutes ( $ url , $ routes ) { $ attributes = [ ] ; foreach ( $ routes as $ route ) { $ request = Request :: create ( implode ( '/' , $ url ) ) ; if ( ! $ route -> matches ( $ request ) ) continue ; $ match = self :: hasAttributesFromUriPath ( $ url , $ route -> uri ( ) , $ a... | Extract attributes from routes . |
49,856 | private static function hasAttributesFromUriPath ( $ url , $ path , & $ attributes ) { $ i = 0 ; $ match = true ; $ path = explode ( '/' , $ path ) ; foreach ( $ path as $ j => $ segment ) { if ( isset ( $ url [ $ i ] ) ) { if ( $ segment !== $ url [ $ i ] ) { self :: extractAttributesFromSegment ( $ url , $ path , $ i... | Check if has attributes from a route . |
49,857 | private static function extractAttributesFromSegment ( $ url , $ path , $ i , $ j , $ segment , & $ attributes ) { if ( preg_match ( '/{[\w]+}/' , $ segment ) ) { $ attributeName = preg_replace ( [ '/{/' , '/\?/' , '/}/' ] , '' , $ segment ) ; $ attributes [ $ attributeName ] = $ url [ $ i ] ; } if ( preg_match ( '/{[\... | Extract attribute from a segment . |
49,858 | private static function checkParsedUrl ( array $ parsed ) { $ scheme = & $ parsed [ 'scheme' ] ; $ user = & $ parsed [ 'user' ] ; $ pass = & $ parsed [ 'pass' ] ; $ host = & $ parsed [ 'host' ] ; $ port = & $ parsed [ 'port' ] ; $ path = & $ parsed [ 'path' ] ; $ path = '/' . ltrim ( $ path , '/' ) ; $ query = & $ pars... | Check parsed URL . |
49,859 | private static function getHierPart ( array $ parsed ) { return strlen ( $ authority = self :: getAuthority ( $ parsed ) ) ? '//' . $ authority . $ parsed [ 'path' ] : $ parsed [ 'path' ] ; } | Get hier part . |
49,860 | private static function getAuthority ( array $ parsed ) { $ host = self :: getHost ( $ parsed ) ; return strlen ( $ userInfo = self :: getUserInfo ( $ parsed ) ) ? $ userInfo . '@' . $ host : $ host ; } | Get authority . |
49,861 | private function registerLocaleNegotiator ( ) { $ this -> bind ( NegotiatorContract :: class , function ( $ app ) { $ manager = $ app [ LocalesManagerContract :: class ] ; return new Negotiator ( $ manager -> getDefaultLocale ( ) , $ manager -> getSupportedLocales ( ) ) ; } ) ; } | Register LocaleNegotiator utility . |
49,862 | private function getTranslatedUrl ( Request $ request ) { $ route = $ request -> route ( ) ; if ( ! ( $ route instanceof Route ) || is_null ( $ route -> getName ( ) ) ) return null ; return $ this -> translateRoute ( $ route -> getName ( ) , $ route -> parameters ( ) ) ; } | Get translated URL . |
49,863 | public function translateRoute ( $ routeName , $ attributes = [ ] ) { if ( empty ( $ attributes ) ) return null ; $ transAttributes = $ this -> fireEvent ( $ this -> getCurrentLocale ( ) , $ routeName , $ attributes ) ; if ( ! empty ( $ transAttributes ) && $ transAttributes !== $ attributes ) return route ( $ routeNam... | Translate route . |
49,864 | private function fireEvent ( $ locale , $ route , $ attributes ) { $ response = event ( self :: EVENT_NAME , [ $ locale , $ route , $ attributes ] ) ; if ( ! empty ( $ response ) ) $ response = array_shift ( $ response ) ; if ( is_array ( $ response ) ) $ attributes = array_merge ( $ attributes , $ response ) ; return ... | Fire translation event . |
49,865 | public function getAttributeValue ( $ key ) { return $ this -> isTranslatableAttribute ( $ key ) ? $ this -> getTranslation ( $ key , $ this -> getLocale ( ) ) : parent :: getAttributeValue ( $ key ) ; } | Get the translated attribute value . |
49,866 | public function getTranslations ( $ key = null ) { if ( $ key !== null ) { $ this -> guardAgainstNonTranslatableAttribute ( $ key ) ; return array_filter ( json_decode ( $ this -> getAttributeFromArray ( $ key ) ?? '' ? : '{}' , true ) ? : [ ] , function ( $ value ) { return $ value !== null && $ value !== false && $ v... | Get the translations for the given key . |
49,867 | public function setTranslation ( $ key , $ locale , $ value ) { $ this -> guardAgainstNonTranslatableAttribute ( $ key ) ; $ translations = $ this -> getTranslations ( $ key ) ; $ oldValue = $ translations [ $ locale ] ?? '' ; if ( $ this -> hasSetMutator ( $ key ) ) { $ this -> { 'set' . Str :: studly ( $ key ) . 'Att... | Set a translation . |
49,868 | public function setTranslations ( $ key , array $ translations ) { $ this -> guardAgainstNonTranslatableAttribute ( $ key ) ; foreach ( $ translations as $ locale => $ translation ) { $ this -> setTranslation ( $ key , $ locale , $ translation ) ; } return $ this ; } | Set the translations . |
49,869 | public function forgetTranslation ( $ key , $ locale ) { $ translations = $ this -> getTranslations ( $ key ) ; unset ( $ translations [ $ locale ] ) ; if ( $ this -> hasSetMutator ( $ key ) ) $ this -> attributes [ $ key ] = $ this -> asJson ( $ translations ) ; else $ this -> setAttribute ( $ key , $ translations ) ;... | Forget a translation . |
49,870 | protected function guardAgainstNonTranslatableAttribute ( $ key ) { if ( ! $ this -> isTranslatableAttribute ( $ key ) ) { throw UntranslatableAttributeException :: make ( $ key , $ this -> getTranslatableAttributes ( ) ) ; } } | Guard against untranslatable attribute . |
49,871 | protected function normalizeLocale ( $ key , $ locale , $ useFallback ) { if ( in_array ( $ locale , $ this -> getTranslatedLocales ( $ key ) ) || ! $ useFallback ) return $ locale ; return config ( 'app.fallback_locale' ) ? : $ locale ; } | Normalize the locale . |
49,872 | private function load ( ) { $ this -> locales -> loadFromArray ( $ this -> getConfig ( 'locales' ) ) ; $ this -> setSupportedLocales ( $ this -> getConfig ( 'supported-locales' ) ) ; $ this -> setDefaultLocale ( ) ; } | Load all locales data . |
49,873 | public function setLocale ( $ locale = null ) { if ( empty ( $ locale ) || ! is_string ( $ locale ) ) { $ locale = $ this -> request ( ) -> segment ( 1 ) ; } if ( $ this -> isSupportedLocale ( $ locale ) ) { $ this -> setCurrentLocale ( $ locale ) ; } else { $ locale = null ; $ this -> getCurrentOrDefaultLocale ( ) ; }... | Set and return current locale . |
49,874 | public function setSupportedLocales ( array $ supportedLocales ) { if ( ! is_array ( $ supportedLocales ) || empty ( $ supportedLocales ) ) throw new UndefinedSupportedLocalesException ; $ this -> supportedLocales = $ this -> filterLocales ( $ supportedLocales ) ; return $ this ; } | Set supported locales . |
49,875 | private function negotiateLocale ( ) { return Negotiator :: make ( $ this -> getDefaultLocale ( ) , $ this -> getSupportedLocales ( ) ) -> negotiate ( $ this -> request ( ) ) ; } | Get negotiated locale . |
49,876 | private function filterLocales ( array $ supportedLocales ) { return $ this -> locales -> filter ( function ( Locale $ locale ) use ( $ supportedLocales ) { return in_array ( $ locale -> key ( ) , $ supportedLocales ) ; } ) ; } | Filter locale collection . |
49,877 | private function updateRegional ( ) { $ currentLocale = $ this -> getCurrentLocaleEntity ( ) ; if ( ! empty ( $ regional = $ currentLocale -> regional ( ) ) ) { $ suffix = $ this -> getConfig ( 'utf-8-suffix' , '.UTF-8' ) ; setlocale ( LC_TIME , $ regional . $ suffix ) ; setlocale ( LC_MONETARY , $ regional . $ suffix ... | Update locale regional . |
49,878 | public function getSupported ( ) { return new SupportedLocaleCollection ( $ this -> filter ( function ( Locale $ locale ) { return in_array ( $ locale -> key ( ) , $ this -> supported ) ; } ) ) ; } | Get supported locales collection . |
49,879 | public function loadFromArray ( array $ locales ) { $ this -> items = [ ] ; foreach ( $ locales as $ key => $ locale ) { $ this -> put ( $ key , Locale :: make ( $ key , $ locale ) ) ; } return $ this ; } | Load locales from array . |
49,880 | protected function getRedirectionUrl ( Request $ request ) { $ locale = $ request -> segment ( 1 , null ) ; if ( $ this -> getSupportedLocales ( ) -> has ( $ locale ) ) return $ this -> isDefaultLocaleHidden ( $ locale ) ? $ this -> localization -> getNonLocalizedURL ( ) : false ; if ( $ this -> getCurrentLocale ( ) !=... | Get redirection . |
49,881 | private function registerLocalization ( ) { $ this -> singleton ( Contracts \ Localization :: class , Localization :: class ) ; if ( $ alias = $ this -> config ( ) -> get ( 'localization.facade' ) ) { $ this -> alias ( $ alias , Facades \ Localization :: class ) ; $ this -> registerAliases ( ) ; } } | Register Localization . |
49,882 | protected function selectDelivery ( ) { $ ltiSession = LtiService :: singleton ( ) -> getLtiSession ( ) ; if ( $ ltiSession -> getLaunchData ( ) -> hasVariable ( LtiLaunchData :: RESOURCE_LINK_TITLE ) ) { $ this -> setData ( 'linkTitle' , $ ltiSession -> getLaunchData ( ) -> getVariable ( LtiLaunchData :: RESOURCE_LINK... | Displays the form to select a delivery |
49,883 | public function setDelivery ( ) { $ link = new core_kernel_classes_Resource ( $ this -> getRequestParameter ( 'link' ) ) ; $ compiled = new core_kernel_classes_Resource ( $ this -> getRequestParameter ( 'uri' ) ) ; $ link -> editPropertyValues ( new core_kernel_classes_Property ( LTIDeliveryTool :: PROPERTY_LINK_DELIVE... | called onSelect of a delivery |
49,884 | public function configureDelivery ( ) { $ compiledDelivery = LTIDeliveryTool :: singleton ( ) -> getDeliveryFromLink ( ) ; if ( is_null ( $ compiledDelivery ) ) { $ this -> selectDelivery ( ) ; } else { $ this -> redirect ( _url ( 'showDelivery' , null , null , array ( 'uri' => $ compiledDelivery -> getUri ( ) ) ) ) ; ... | Either displays the currently associated delivery or calls selectDelivery in order to allow the user to select a delivery |
49,885 | public function showDelivery ( ) { $ delivery = new core_kernel_classes_Resource ( $ this -> getRequestParameter ( 'uri' ) ) ; $ this -> setData ( 'delivery' , $ delivery ) ; $ ltiSession = LtiService :: singleton ( ) -> getLtiSession ( ) ; if ( $ ltiSession -> getLaunchData ( ) -> hasVariable ( LtiLaunchData :: RESOUR... | Displays the currently associated delivery |
49,886 | protected function showControls ( ) { $ themeService = $ this -> getServiceManager ( ) -> get ( ThemeServiceInterface :: SERVICE_ID ) ; if ( $ themeService instanceof ThemeServiceInterface || $ themeService instanceof LtiHeadless ) { return ! $ themeService -> isHeadless ( ) ; } return false ; } | Defines if the top and bottom action menu should be displayed or not |
49,887 | public function ltiOverview ( ) { $ this -> setData ( 'delivery' , $ this -> getRequestParameter ( 'delivery' ) ) ; $ this -> setData ( 'allowRepeat' , true ) ; $ this -> setView ( 'learner/overview.tpl' ) ; } | Shown uppon returning to a finished delivery execution |
49,888 | public function finishDeliveryExecution ( ) { $ deliveryExecution = null ; if ( $ this -> hasRequestParameter ( 'deliveryExecution' ) ) { $ deliveryExecution = ServiceProxy :: singleton ( ) -> getDeliveryExecution ( $ this -> getRequestParameter ( 'deliveryExecution' ) ) ; if ( $ deliveryExecution -> getState ( ) !== D... | Redirect user to return URL |
49,889 | public function collect ( $ force = false ) { $ active = $ this -> getPersistence ( ) -> get ( self :: class ) ; if ( ! $ active || $ force ) { $ action = new GetActiveDeliveryExecution ( ) ; $ this -> propagate ( $ action ) ; $ active = $ action -> getNumberOfActiveActions ( ) ; $ this -> getPersistence ( ) -> set ( s... | Collect values caches |
49,890 | public function index ( ) { $ feedBackMessage = '' ; $ selectedDelivery = new core_kernel_classes_Resource ( tao_helpers_Uri :: decode ( $ this -> getRequestParameter ( 'uri' ) ) ) ; $ this -> setData ( 'launchUrl' , LTIDeliveryTool :: singleton ( ) -> getLaunchUrl ( array ( 'delivery' => $ selectedDelivery -> getUri (... | Displays the LTI link for the consumer with respect to the currently selected delviery at tdelviery level checks if the delviery is related to a resultserver cofnigured with the correct outcome service impelmentation |
49,891 | protected function showThankyou ( LtiLaunchData $ launchData ) { if ( ! $ launchData -> hasReturnUrl ( ) ) { return true ; } if ( $ launchData -> hasVariable ( DeliveryTool :: PARAM_SKIP_THANKYOU ) ) { switch ( $ launchData -> getVariable ( DeliveryTool :: PARAM_SKIP_THANKYOU ) ) { case 'true' : return false ; case 'fa... | Whenever or not to show the thank you screen |
49,892 | protected function validateLtiParams ( LtiLaunchData $ launchData ) { if ( $ launchData -> hasVariable ( self :: CUSTOM_LTI_SECURE ) ) { $ val = mb_strtolower ( $ launchData -> getVariable ( self :: CUSTOM_LTI_SECURE ) ) ; if ( $ val !== 'true' && $ val !== 'false' ) { throw new LtiException ( __ ( 'Wrong value of "sec... | Validate and prepare launch variables |
49,893 | public function storeResultAlias ( $ deliveryExecutionId , $ resultId ) { $ data = [ self :: DELIVERY_EXECUTION_ID => $ deliveryExecutionId , self :: RESULT_ID => $ resultId , ] ; $ queryBuilder = $ this -> getQueryBuilder ( ) ; $ queryBuilder -> delete ( $ this -> getTableName ( ) ) ; $ queryBuilder -> where ( self ::... | Add record to the storage |
49,894 | protected function verifyToken ( \ core_kernel_classes_Resource $ delivery , User $ user ) { $ propMaxExec = $ delivery -> getOnePropertyValue ( $ this -> getProperty ( DeliveryContainerService :: PROPERTY_MAX_EXEC ) ) ; $ maxExec = is_null ( $ propMaxExec ) ? 0 : $ propMaxExec -> literal ; $ currentSession = $ this ->... | Check Max . number of executions |
49,895 | public function startDelivery ( core_kernel_classes_Resource $ delivery , core_kernel_classes_Resource $ link , User $ user ) { $ this -> getAuthorizationProvider ( ) -> verifyStartAuthorization ( $ delivery -> getUri ( ) , $ user ) ; $ assignmentService = $ this -> getServiceLocator ( ) -> get ( LtiAssignment :: SERVI... | Start a new delivery execution |
49,896 | private function getDelivery ( ) { $ returnValue = null ; if ( $ this -> hasRequestParameter ( 'delivery' ) ) { $ returnValue = new core_kernel_classes_Resource ( $ this -> getRequestParameter ( 'delivery' ) ) ; } else { $ launchData = LtiService :: singleton ( ) -> getLtiSession ( ) -> getLaunchData ( ) ; $ launchData... | Returns the delivery associated with the current link either from url or from the remote_link if configured returns null if none found |
49,897 | public function getUrl ( ) { try { if ( $ this -> getRequestMethod ( ) != \ Request :: HTTP_GET ) { throw new \ common_exception_NotImplemented ( 'Only GET method is accepted to request this service.' ) ; } if ( ! $ this -> hasRequestParameter ( 'deliveryId' ) ) { $ this -> returnFailure ( new \ common_exception_Missin... | return a LTI link URI from a valid delivery id |
49,898 | public function getDriver ( $ driver = null ) { $ driver = ( $ driver ) ? : array_get ( $ this -> config , 'driver' , '' ) ; $ method = 'create' . ucfirst ( camel_case ( $ driver ) ) . 'Driver' ; if ( ! method_exists ( $ this , $ method ) ) { throw new InvalidDriverException ( sprintf ( 'Driver [%s] not supported.' , $... | Get the driver based on config . |
49,899 | public function getRaw ( $ ip ) { try { return json_decode ( $ this -> guzzle -> get ( $ this -> getUrl ( $ ip ) ) -> getBody ( ) , true ) ; } catch ( RequestException $ e ) { } return [ ] ; } | Get the raw GeoIP info using ipstack . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.