idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
13,700 | protected function validateType ( ) : bool { if ( $ this -> validateMimeType ( ) == FALSE ) return FALSE ; if ( $ this -> validateFileSize ( ) == FALSE ) return FALSE ; if ( $ this -> uploadFile ( ) == FALSE ) return FALSE ; return TRUE ; } | Validates file by it s type . |
13,701 | public function setPrice ( $ price ) { NumericValidator :: validate ( $ price , "Price" ) ; $ price = Formatter :: formatToPrice ( $ price , $ this -> getCurrency ( ) ) ; $ this -> price = $ price ; return $ this ; } | Item cost . 10 characters max . |
13,702 | public function setTax ( $ tax ) { NumericValidator :: validate ( $ tax , "Tax" ) ; $ tax = Formatter :: formatToPrice ( $ tax , $ this -> getCurrency ( ) ) ; $ this -> tax = $ tax ; return $ this ; } | Tax of the item . |
13,703 | public function setLocale ( $ locale ) { $ this -> locale = trim ( $ locale ) ; $ this -> primaryLanguage = IntlLocale :: getPrimaryLanguage ( $ this -> locale ) ; } | Set the locale |
13,704 | public function setClass ( $ classname ) { $ this -> class = trim ( $ classname , '\\' ) ; $ this -> reflection = null ; $ this -> reset ( ) ; return $ this ; } | Set name of class |
13,705 | public function setReflection ( ReflectionClass $ reflection ) { $ this -> reflection = $ reflection ; $ this -> class = $ reflection -> getName ( ) ; $ this -> reset ( ) ; return $ this ; } | Get reflection of class |
13,706 | protected function getReflection ( ) { if ( $ this -> reflection === null ) { try { $ this -> reflection = new ReflectionClass ( $ this -> class ) ; } catch ( ReflectionException $ exception ) { throw new InitializationFailure ( 'Error occurred while service initialization by class "' . $ this -> class . '"' , 0 , $ ex... | Get class reflection |
13,707 | public function createNamespace ( $ name ) { if ( isset ( $ this -> _namespaces [ $ name ] ) ) { return $ this -> _namespaces [ $ name ] ; } $ namespace = new Bag ( $ name ) ; if ( $ this -> hasLocator ( ) ) { $ namespace -> setDi ( $ this -> getLocator ( ) ) ; } $ this -> _namespaces [ $ name ] = $ namespace ; return ... | Create the session s namespace |
13,708 | public static function init ( $ appDir , array $ configFiles ) { self :: $ loaders = [ new JsonLoader ( ) , new YamlLoader ( ) , new PhpLoader ( ) ] ; self :: $ appDir = $ appDir ; self :: $ configFiles = $ configFiles ; } | Initialise the DI container builder |
13,709 | public static function createContainer ( ) { $ resolver = new ReferenceResolver ( ) ; $ builder = new ContainerBuilder ( $ resolver , [ self :: $ appDir ] ) ; foreach ( self :: $ loaders as $ loader ) { $ builder -> addLoader ( $ loader ) ; } $ builder -> setApplicationRootDirectory ( self :: $ appDir ) ; $ builder -> ... | Build a new DI container |
13,710 | public function getUserInfo ( ) { return $ this -> user ? ( $ this -> pass ? $ this -> user . ':' . $ this -> pass : $ this -> user ) : '' ; } | Get uri userinfo part |
13,711 | public function getResponse ( ) { $ l = $ this -> action -> layout ( 'output' ) ; switch ( $ l ) { case 'object' : case 'object_list' : case 'hash' : case 'hash_list' : return $ this -> envelope -> response -> { $ this -> action -> getNamespace ( 'output' ) } ; default : return $ this -> envelope -> response ; } } | For known layouts namespaced response is returned or else the data is returned as is . |
13,712 | public function addSubMenuItem ( string $ k , string $ v = '' , string $ prefix = P ) { if ( ! $ this -> isAddingItemsAllowed ( ) ) { return $ this ; } if ( ! $ v ) { $ v = $ k ; } if ( ! isset ( $ this -> _menu [ $ prefix ] ) ) { return $ this ; } if ( isset ( $ this -> _menu [ $ prefix ] [ $ k ] ) ) { return $ this ;... | Add submenu item |
13,713 | public function addHelpText ( string $ text , string $ link = null , $ critical = false ) { if ( ! $ link ) { $ this -> help_texts [ ] = $ text ; } else { $ this -> help_texts [ ] = [ $ text , $ link ] ; } if ( $ critical ) $ this -> critical_help_texts = true ; return $ this ; } | Add one line of help text for menu item |
13,714 | public function addLabelForMenuItem ( string $ label , string $ do = P_DO , string $ p = P ) { $ this -> menu_labels [ $ p ] [ $ do ] = $ label ; return $ this ; } | Set text for label near menu item |
13,715 | private function processRevisions ( array $ calendarItems ) : void { $ revisedDates = [ ] ; $ originalCalendarItems = [ ] ; foreach ( $ calendarItems as $ calendarItem ) { if ( $ calendarItem -> getOriginalDate ( ) ) { $ revisedDates [ $ calendarItem -> getId ( ) ] [ ] = $ calendarItem -> getOriginalDate ( ) ; } else {... | Process revisions . Adds revisions as exceptions to the original calendar item . |
13,716 | public function getWorkspaces ( ) { return $ this -> getCachedProperty ( 'workspaces' , function ( ) { $ result = [ ] ; $ items = $ this -> getValue ( 'workspaces' ) ; if ( is_array ( $ items ) ) { foreach ( $ items as $ item ) { try { $ result [ ] = new Workspace ( $ item ) ; } catch ( \ InvalidArgumentException $ e )... | Return Workspaces that contain this application . |
13,717 | protected function parseContent ( $ content ) { $ lines = explode ( PHP_EOL , $ content ) ; $ result = [ ] ; foreach ( $ lines as $ lineNm => $ lineRaw ) { if ( empty ( $ lineRaw ) ) { continue ; } $ line = str_getcsv ( $ lineRaw , $ this -> csvDelimiter , $ this -> csvEnclosure ) ; if ( count ( $ line ) < 2 ) { $ temp... | Parse the CSV - content |
13,718 | protected function markAsInitialized ( $ locale , $ domain ) { if ( ! isset ( $ this -> initializedCatalogs [ $ locale ] ) ) { $ this -> initializedCatalogs [ $ locale ] = [ ] ; } $ this -> initializedCatalogs [ $ locale ] [ $ domain ] = true ; } | Mark the resource as initialized |
13,719 | public static function & getReference ( & $ storage , $ key ) { $ keys = explode ( '.' , $ key ) ; foreach ( $ keys as $ key ) $ storage = & $ storage [ $ key ] ; return $ storage ; } | Get referenced value |
13,720 | public static function each ( array & $ storage , \ Closure $ callback , array $ prefix = array ( ) ) { foreach ( $ storage as $ key => & $ value ) { if ( is_array ( $ value ) ) static :: each ( $ value , $ callback , array_merge ( $ prefix , array ( $ key ) ) ) ; else $ callback ( implode ( '.' , array_merge ( $ prefi... | Recursively loop through multidimensional array With every loop receive a dotted key |
13,721 | public static function has ( array $ storage , $ key ) { $ keys = explode ( '.' , $ key ) ; foreach ( $ keys as $ key ) { if ( ! isset ( $ storage [ $ key ] ) ) return false ; $ storage = $ storage [ $ key ] ; } return true ; } | Check key existence |
13,722 | public function afterAddStockDataToCollection ( \ Magento \ CatalogInventory \ Model \ ResourceModel \ Stock \ Status $ subject , \ Magento \ Catalog \ Model \ ResourceModel \ Product \ Collection $ result ) { $ select = $ result -> getSelect ( ) ; $ from = $ select -> getPart ( \ Magento \ Framework \ DB \ Select :: F... | Replace default stock id in the where clause by stock id corresponded with store id . |
13,723 | protected function serverInfo ( Infoset $ info ) { $ infoTable = $ this -> createTable ( ) ; $ infoTable -> setTitle ( 'Info' ) ; if ( ! empty ( $ _SERVER [ 'REQUEST_TIME' ] ) ) { $ infoTable [ ] = [ 'Request time: ' , date ( DATE_RFC3339 , $ _SERVER [ 'REQUEST_TIME' ] ) ] ; } foreach ( self :: $ serverInfo as $ groupN... | Collect the server information |
13,724 | protected function collectData ( Infoset $ info , array $ source , $ title ) { $ infoTable = $ this -> createTable ( ) ; $ infoTable -> setTitle ( $ title ) ; foreach ( $ source as $ name => $ value ) { if ( is_array ( $ value ) ) { foreach ( $ value as $ key => $ val ) { if ( strlen ( $ val ) > 1024 ) { $ val = substr... | Collect the data |
13,725 | public function getResource ( ) { if ( null === $ this -> handle ) { $ this -> handle = fopen ( $ this -> path , 'r' ) ; } return $ this -> handle ; } | Open file for reading and return related resource . |
13,726 | public function getProfiler ( ) { if ( $ this -> _profiler === null ) { $ this -> _profiler = new Profiler ( ) ; $ this -> onProfilerInit ( $ this -> _profiler ) ; } return $ this -> _profiler ; } | Get a profiler |
13,727 | public function configureFilesystemAdapter ( ContainerBuilder $ container , array $ config ) : void { if ( $ container -> hasDefinition ( 'bkstg.core.adapter.filesystem.do_spaces' ) && isset ( $ config [ 'filesystem' ] ) ) { $ container -> getDefinition ( 'bkstg.core.adapter.filesystem.do_spaces' ) -> replaceArgument (... | Configure the filesystem adapter . |
13,728 | public function configureCdnAdapter ( ContainerBuilder $ container , array $ config ) : void { if ( $ container -> hasDefinition ( 'bkstg.core.cdn.private_do_spaces' ) && isset ( $ config [ 'cdn' ] ) ) { $ container -> getDefinition ( 'bkstg.core.cdn.private_do_spaces' ) -> replaceArgument ( 0 , $ config [ 'cdn' ] [ 'b... | Configure the CDN adapter . |
13,729 | public static function expiryDialog ( ) { $ acl = \ Application :: $ controller -> acl ; if ( ! empty ( self :: $ object ) && \ Application :: get ( 'flag.global.session.expiry_dialog' ) && \ User :: authorized ( ) && ! empty ( $ acl [ 'authorized' ] ) && empty ( $ acl [ 'public' ] ) ) { \ Layout :: onhtml ( self :: $ ... | Add expiry dialog |
13,730 | public function data ( ) { $ ratings = RatingTotalModel :: with ( [ 'rateable' => function ( $ query ) { $ query -> with ( [ 'ratings' , 'ratingTotal' ] ) -> select ( [ 'id' , 'title' , 'slug' ] ) ; } ] ) -> get ( ) ; $ ratings = $ ratings -> filter ( function ( $ value , $ key ) { return isset ( $ value -> rateable ) ... | DataTables ServerSide . |
13,731 | private function checkError ( ResponseInterface $ response , $ url ) { if ( ( $ response -> getStatusCode ( ) == 200 ) || ( $ response -> getStatusCode ( ) == 201 ) ) { return ; } switch ( $ response -> getHeader ( 'Content-Type' ) ) { case 'text/plain' : throw new \ RuntimeException ( 'Error: ' . $ response -> getBody... | Check the response for an error . |
13,732 | public function post ( $ command , $ params = null , $ postcontenttype = 'application/json' ) { $ url = $ command ; $ headers = array ( 'Content-Type' => $ postcontenttype ) ; $ content = $ params ; if ( $ postcontenttype == 'application/json' ) { $ content = json_encode ( $ params ) ; } try { $ response = $ this -> cl... | Perform a post request . |
13,733 | public function execute ( $ command , $ params = null ) { $ url = $ command ; if ( substr ( $ url , - 1 ) !== '/' ) { $ url .= '/' ; } if ( $ params ) { $ parameters = array ( ) ; foreach ( $ params as $ k => $ v ) { if ( strlen ( $ v ) ) { $ parameters [ ] = urlencode ( $ k ) . '=' . urlencode ( $ v ) ; } else { $ par... | Execute a command on the API . |
13,734 | public function executeJson ( $ command , $ params = null ) { return json_decode ( $ this -> execute ( $ command , $ params ) , true ) ; } | Execute a command on the API and return the content as json decoded array .. |
13,735 | public function getEmbedHtml ( ) : string { if ( null === $ this -> assetHelper && null === $ this -> packages ) { throw new AssetIntegrationFailedException ( "No asset integration extension found. Please either install `becklyn/assets-bundle` or `symfony/asset` to use this bundle." ) ; } $ trackJsToken = $ this -> hos... | Returns the embed HTML for TrackJS |
13,736 | protected static function setPageDetails ( string $ title = NULL , string $ description = NULL ) { self :: $ title = $ title ; self :: $ description = $ description ; } | Sets the Page Details . |
13,737 | public function execute ( ) { $ this -> determineMethod ( ) ; $ this -> user -> { $ this -> method } ( ) ; return Response :: passed ( $ this -> getMessage ( ) ) -> route ( 'admin.users.index' ) ; } | Determine what to do on the user . |
13,738 | protected function determineMethod ( ) { $ methods = [ 'block' => [ 'unblock' , 'block' ] , 'delete' => [ 'restore' , 'delete' ] , 'activate' => [ 'activate' ] , 'resetPassword' => [ 'resetPassword' ] , 'resendInvite' => [ 'resendInvite' ] , 'revokeInvite' => [ 'revokeInvite' ] , ] ; $ this -> method = array_get ( $ me... | Based on the status and action determine the method to call on the user object . |
13,739 | protected function initExact ( $ locale , $ domain ) { $ source = $ this -> getCatalogContent ( $ locale , $ domain ) ; if ( $ source !== false ) { $ catalog = parse_ini_string ( $ source ) ; if ( $ catalog === false ) { throw new ParseError ( 'Error has occurred while parsing INI file for the locale: "' . $ locale . '... | Initialize the exact locale and domain |
13,740 | protected function initManyDomains ( $ locale , $ domain ) { $ source = $ this -> getCatalogContent ( $ locale , $ domain ) ; if ( $ source !== false ) { $ domains = parse_ini_string ( $ source , true ) ; if ( $ domains === false ) { throw new ParseError ( 'Error has occurred while parsing INI file for the locale: "' .... | Initialize all domains for the exact locale |
13,741 | protected function initManyLocales ( $ locale , $ domain ) { $ source = $ this -> getCatalogContent ( $ locale , $ domain ) ; if ( $ source !== false ) { $ locales = parse_ini_string ( $ source , true ) ; if ( $ locales === false ) { throw new ParseError ( 'Error has occurred while parsing INI file for the domain: "' .... | Initialize all locales for the exact domain |
13,742 | public function report ( $ account_id , $ report_type , array $ parameters = [ ] ) { $ parameters = array_merge ( [ 'type' => $ report_type ] , $ parameters ) ; return $ this -> merchantApi -> call ( 'get' , 'accounts/' . $ account_id . '/report?' . http_build_query ( $ parameters ) ) -> toArray ( ) ; } | Generates a report for a specific account Look at defined constants to see possible report types . Further info can be found in docs . |
13,743 | public function exportFilesSamples ( & $ form ) { $ result = '' ; $ formats = \ Object \ Content \ ImportFormats :: getStatic ( ) ; $ temp = [ ] ; foreach ( $ formats as $ k => $ v ) { $ temp [ ] = \ HTML :: a ( [ 'href' => '?export_file_with_format=' . $ k , 'value' => 'Import.' . $ v [ 'extension' ] ] ) ; } $ result ... | Export file samples |
13,744 | public function resolve ( string $ path ) : string { if ( 1 === \ preg_match ( '~^@(?<bundle>[^/]+)(?<rest>.*?)$~i' , $ path , $ matches ) ) { $ rest = ltrim ( $ matches [ "rest" ] , "/" ) ; return $ this -> kernel -> locateResource ( "@{$matches['bundle']}Bundle/Resources/views/{$rest}" ) ; } return rtrim ( $ this -> ... | Resolves the configured layout directory path |
13,745 | public function SetReturnType ( \ Peg \ Lib \ Definitions \ Element \ ReturnType $ return_type ) { $ return_type -> overload = & $ this ; $ this -> return_type = $ return_type ; return $ this ; } | Helper function to set the overload return type . |
13,746 | private function handleInactiveUser ( ) { event ( new UserFailedLogin ( 'inactive' ) ) ; session ( [ 'inactive_email' => auth ( ) -> user ( ) -> email ] ) ; auth ( ) -> logout ( ) ; return Response :: failed ( 'Your account is not yet activated.' ) -> route ( 'auth.activation.inactive' ) ; } | Called when the user is inactive . |
13,747 | private function handleSuccessfulLogin ( ) { event ( new UserLoggedIn ( auth ( ) -> user ( ) ) ) ; auth ( ) -> user ( ) -> updateLogin ( ) ; return Response :: passed ( 'You have been logged in.' ) -> route ( 'home' ) ; } | Called when the user has passed all authentication checks . |
13,748 | public function update ( array $ address_template ) { if ( ! isset ( $ address_template [ 'id' ] ) ) { throw new MonetivoException ( '$address_template["id"] is required' ) ; } return $ this -> merchantApi -> call ( 'put' , 'addresses_templates/' . $ address_template [ 'id' ] , [ 'form_params' => $ address_template ] )... | Updates address template |
13,749 | public function query ( $ expression , array $ properties , array $ orderBy = null , $ limit = null , $ offset = 0 ) { $ properties = array_flip ( $ properties ) ; $ properties [ 'id' ] = true ; $ properties = array_keys ( $ properties ) ; if ( ! $ orderBy ) { $ orderBy = [ 'id' => 'Ascending' ] ; } $ payload = [ 'expr... | Get items with a custom query . |
13,750 | public function get ( $ id ) { $ response = $ this -> client -> sendRequest ( $ this -> getBase ( ) . '/' . $ id ) ; try { return new Item ( $ response ) ; } catch ( \ InvalidArgumentException $ e ) { throw new UnexpectedValueException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } } | Get Item . |
13,751 | public function create ( $ containerId , Item $ item ) { $ properties = $ item -> export ( ) [ 'properties' ] ; if ( count ( $ properties ) === 0 ) { throw new \ InvalidArgumentException ( 'Item should has at least one property!' ) ; } return $ this -> client -> sendRequest ( $ this -> getBase ( ) . '/' . $ containerId... | Create Item . |
13,752 | public function getTransitions ( $ id ) { $ response = $ this -> client -> sendRequest ( $ this -> getBase ( ) . '/' . $ id . '/Transition' ) ; $ result = [ ] ; if ( ! is_array ( $ response ) ) { throw new UnexpectedValueException ( 'Array expected, but got ' . gettype ( $ response ) ) ; } foreach ( $ response as $ ite... | Return possible Transitions for Item . |
13,753 | public function transit ( $ itemId , $ transitionId ) { $ this -> client -> sendRequest ( $ this -> getBase ( ) . '/' . $ itemId . '/Transition/' . $ transitionId , 'POST' ) ; } | Transit Item to another state . |
13,754 | public function hasScope ( string $ scope ) : bool { return ! Group :: create ( ) -> hasExtension ( GroupExtension :: class ) || $ this -> getMember ( ) -> Groups ( ) -> filter ( [ 'Scopes.Name' => $ scope ] ) -> count ( ) > 0 ; } | Checks whether the member has a scope . Only works if the GroupExtension has been configured . |
13,755 | public static function connect ( ) { if ( self :: $ memcache === null ) { $ config = \ Skeleton \ Object \ Config :: $ cache_handler_config ; self :: $ memcache = new \ Memcache ( ) ; self :: $ memcache -> connect ( $ config [ 'hostname' ] , $ config [ 'port' ] ) ; } return self :: $ memcache ; } | Get the current memcache object |
13,756 | public function update ( array $ pos ) { if ( ! isset ( $ pos [ 'id' ] ) ) { throw new MonetivoException ( '$pos["id"] is required' ) ; } return $ this -> merchantApi -> call ( 'put' , 'pos/' . $ pos [ 'id' ] , [ 'form_params' => $ pos ] ) -> toArray ( ) ; } | Updates as POS |
13,757 | public static function plainNumber ( string $ value ) : int { $ temp = explode ( 'ext' , $ value ) ; $ result = preg_replace ( '/[^0-9]/' , '' , $ temp [ 0 ] ) ; if ( strlen ( $ result ) == 11 && $ result [ 0 ] == 1 ) { $ result = substr ( $ result , 1 ) ; } return $ result ; } | Generate plain number |
13,758 | public function sendEmail ( $ email ) { $ user = $ this -> users -> where ( 'email' , $ email ) -> first ( ) ; if ( ! is_null ( $ user ) ) { $ user -> generatePasswordResetToken ( ) ; } } | If the email exists generate a reset token for that user . |
13,759 | public function updatePassword ( $ token , $ email , $ password ) { $ token = $ this -> tokens -> findByToken ( $ token ) ; if ( $ token -> user -> email !== $ email ) { return Response :: failed ( 'The email does not match this token.' ) -> route ( 'auth.password.reset' ) ; } $ token -> user -> resetPassword ( $ passw... | Attempt to update the user s password . |
13,760 | public static function forMissingClosing ( array $ open ) { foreach ( $ open as $ i => $ item ) { $ open [ $ i ] = sprintf ( self :: ERROR_LINE , $ item [ 'value' ] , $ item [ 'line' ] ) ; } $ message = implode ( self :: ERROR_AND , $ open ) ; $ message = sprintf ( self :: ERROR_MISSING_CLOSING , $ message ) ; return n... | Triggered when we are missing closing tags |
13,761 | public static function forCompileError ( array $ error , $ code , $ limit = 25 ) { $ code = explode ( "\n" , $ code ) ; $ start = $ error [ 'line' ] - $ limit ; if ( $ start < 0 ) { $ start = 0 ; } $ code = array_splice ( $ code , $ start , $ limit * 2 ) ; foreach ( $ code as $ i => $ line ) { $ code [ $ i ] = ( ++ $ s... | Triggered when there is a compiler error |
13,762 | public function setLines ( array $ lines ) { $ translator = $ this -> factory -> getTranslator ( ) ; if ( $ translator instanceof Translator ) { $ translator -> setLines ( $ lines ) ; } } | Set the language lines used by the translator . |
13,763 | public function optionsQueryData ( & $ options ) { if ( empty ( $ options [ 'column_prefix' ] ) ) { $ options [ 'column_prefix' ] = $ this -> column_prefix ; } if ( ! array_key_exists ( 'pk' , $ options ) ) { $ options [ 'pk' ] = $ this -> pk ; } $ pk = $ options [ 'pk' ] ; if ( $ this -> tenant && ! isset ( $ options ... | Query data for options |
13,764 | public static function processOptionsExistingValuesAndSkipValues ( $ value , $ existing_values , $ skip_values ) : bool { if ( ! empty ( $ existing_values ) ) { if ( ! is_array ( $ existing_values ) ) $ existing_values = [ $ existing_values ] ; if ( in_array ( $ value , $ existing_values ) ) return true ; } if ( ! empt... | Process options existing values and skip values |
13,765 | public static function optionJsonExtractKey ( string $ key , array $ columns , string $ delimiter = '::' ) : string { $ decoded = json_decode ( $ key , true ) ; $ temp = [ ] ; foreach ( $ columns as $ v ) { $ temp [ ] = $ decoded [ $ v ] ; } return implode ( $ delimiter , $ temp ) ; } | Extract key for JSON options |
13,766 | public function widget ( $ args , $ instance ) { $ this -> mustacheRender = App :: get ( MustacheRender :: class ) ; $ this -> i18n = App :: get ( I18n :: class ) ; $ instance [ 'active' ] = $ this -> isActive ( ) ; echo $ this -> renderFrontendWidget ( $ args , $ instance ) ; } | Creating widget front - end . |
13,767 | public function update ( $ newInstance , $ oldInstance ) { $ instance = [ ] ; $ instance [ 'title' ] = ( ! empty ( $ newInstance [ 'title' ] ) ) ? strip_tags ( $ newInstance [ 'title' ] ) : '' ; return $ instance ; } | Updating widget replacing old instances with new . |
13,768 | protected function renderBackendForm ( $ instance , array $ fields ) { $ fieldIds = [ ] ; $ fieldNames = [ ] ; foreach ( $ fields as $ f ) { $ fieldIds = array_merge ( $ fieldIds , [ $ f => $ this -> get_field_id ( $ f ) , ] ) ; $ fieldNames = array_merge ( $ fieldNames , [ $ f => $ this -> get_field_name ( $ f ) , ] )... | Render backend form . |
13,769 | protected function renderFrontendWidget ( $ args , $ instance ) { $ instance [ 'widgetName' ] = $ this -> className ; return $ this -> mustacheRender -> render ( $ this -> getTemplateName ( static :: $ frontFileName ) , [ 'args' => $ args , 'instance' => $ instance , ] ) ; } | Render fronted widget . |
13,770 | protected function getTemplateName ( $ fileName ) { $ pathFn = function ( $ dir ) use ( $ fileName ) { return static :: $ widgetTemplateDir . '/' . $ dir . '/' . $ fileName ; } ; $ pathToCheckFn = function ( $ path ) { return APP_DIR . '/templates/' . $ path . '.mustache' ; } ; $ path = $ pathFn ( $ this -> className )... | Create the template name string . |
13,771 | public function transform ( $ value ) { if ( null === $ value ) { return '' ; } if ( ! $ value instanceof \ DateTime ) { throw new UnexpectedTypeException ( $ value , '\DateTime' ) ; } $ value = clone $ value ; try { $ value -> setTimezone ( new \ DateTimeZone ( $ this -> outputTimezone ) ) ; } catch ( \ Exception $ e ... | Transforms a DateTime object into a date string with the configured format and timezone |
13,772 | public function update ( array $ contact_template ) { if ( ! isset ( $ contact_template [ 'id' ] ) ) { throw new MonetivoException ( '$contact["type"] and $contact["id"] are required' ) ; } return $ this -> merchantApi -> call ( 'put' , 'contacts_templates/' . $ contact_template [ 'id' ] , [ 'form_params' => $ contact_... | Updates contact template |
13,773 | protected function getModelArguments ( ) : array { $ models = $ this -> argument ( 'models' ) ; if ( empty ( $ models ) ) { $ models = [ '\Laranix\Auth\Email\Verification\Verification' , '\Laranix\Auth\Password\Reset\Reset' ] ; } return $ this -> validateArgs ( $ models ) ; } | Get models to use |
13,774 | protected function validateArgs ( array $ models ) : array { $ validModels = [ ] ; foreach ( $ models as $ model ) { if ( ! class_exists ( $ model ) ) { $ this -> error ( 'Class "' . $ model . '"" does not exist' ) ; $ this -> line ( '' ) ; } elseif ( ! ( new \ ReflectionClass ( $ model ) ) -> isInstantiable ( ) ) { $ ... | Validate given arguments models |
13,775 | public function location ( Request $ request ) { $ lesson = new Lesson ( ) ; $ lesson -> location_id = $ request -> input ( 'location' ) ; $ lesson -> state = 'step1' ; $ lesson -> save ( ) ; try { $ lesson -> step1step2 ( ) ; } catch ( IllegalStateTransitionException $ e ) { return [ 'status' => 'Error saving user Ill... | Save lesson location |
13,776 | protected function parseSelector ( $ selector , \ SplFileInfo $ file , $ x , $ y = 0 ) { return str_replace ( array ( '{{filename}}' , '{{x}}' , '{{y}}' ) , array ( $ this -> asciify ( $ file ) , $ x , $ y ) , $ selector ) ; } | Parses the CSS selector . |
13,777 | protected function save ( Configuration $ config , ImageInterface $ image , $ styles ) { $ this -> createDirectory ( array ( $ config -> getImage ( ) , $ config -> getStylesheet ( ) ) ) ; try { $ image -> save ( $ config -> getImage ( ) , $ config -> getOptions ( ) ) ; } catch ( \ RuntimeException $ e ) { throw new \ R... | Saves the image sprite and stylesheet . |
13,778 | protected function createDirectory ( $ paths ) { if ( ! is_array ( $ paths ) ) { $ paths = array ( $ paths ) ; } foreach ( $ paths as $ path ) { if ( ! is_dir ( $ dir = dirname ( $ path ) ) && false === @ mkdir ( $ dir , 0777 , true ) ) { throw new \ RuntimeException ( sprintf ( 'Unable to create directory "%s".' , $ d... | Creates the given directory . |
13,779 | public function verify ( $ ip , $ port ) { $ errorNumber = null ; $ errorString = null ; $ fp = @ fsockopen ( $ ip , $ port , $ errorNumber , $ errorString , $ this -> ttl ) ; if ( $ fp ) { fclose ( $ fp ) ; return true ; } return false ; } | Spend a few tenths of a second opening a socket to the requested IP and port |
13,780 | static protected function isExecAvailable ( ) { if ( self :: $ _execAvailable === null ) { $ disabled = explode ( ',' , ini_get ( 'disable_functions' ) ) ; $ disabled = array_map ( 'trim' , $ disabled ) ; self :: $ _execAvailable = ! in_array ( 'exec' , $ disabled , true ) ; } return self :: $ _execAvailable ; } | Is system function available |
13,781 | protected function getData ( $ file , $ path ) { $ options = ( int ) stream_get_contents ( $ file , self :: DATA_OFFSET - self :: OPTIONS_OFFSET - 1 , self :: OPTIONS_OFFSET ) ; if ( $ options === false ) { fclose ( $ file ) ; throw new OperationFailed ( 'Unable to get the metadata content from: ' . $ path ) ; } $ data... | Get the cache data |
13,782 | protected function putData ( $ file , $ path , $ data ) { fseek ( $ file , self :: DATA_OFFSET ) ; if ( fwrite ( $ file , serialize ( $ data ) ) === false ) { fclose ( $ file ) ; throw new OperationFailed ( 'Unable to puth the cache content to: ' . $ path ) ; } ftruncate ( $ file , ftell ( $ file ) ) ; fclose ( $ file ... | Put the cache data |
13,783 | public function openFile ( $ path , $ mode = 'r' ) { if ( ! is_file ( $ path ) ) { return false ; } $ file = fopen ( $ path , $ mode ) ; if ( $ file === false ) { throw new OperationFailed ( 'Unable to open the file: ' . $ path ) ; } $ expire = fread ( $ file , self :: OPTIONS_OFFSET - 1 ) ; if ( $ expire === false ) {... | Open the file |
13,784 | protected function preparePath ( $ id ) { if ( ! is_scalar ( $ id ) ) { $ id = json_encode ( $ id ) ; } $ filename = $ this -> prefix . '_' . md5 ( $ id ) ; return $ this -> getCachePath ( ) . DIRECTORY_SEPARATOR . $ filename ; } | Prepare the path by cache id |
13,785 | public function setCachePath ( $ path ) { $ path = rtrim ( $ path , DIRECTORY_SEPARATOR ) ; $ path = realpath ( $ path ) ; if ( $ path === false ) { throw new NoPath ( 'Invalid path: "' . func_get_arg ( 0 ) . '"' ) ; } if ( ! is_dir ( $ path ) ) { throw new NoPath ( 'Path must be a directory: "' . $ path . '"' ) ; } if... | Set the cache path |
13,786 | public function getCachePath ( ) { if ( $ this -> path === null ) { $ this -> path = rtrim ( sys_get_temp_dir ( ) , DIRECTORY_SEPARATOR ) ; } return $ this -> path ; } | Get the cache path |
13,787 | public function setCompressionLevel ( $ level ) { $ level = ( int ) $ level ; if ( $ level < 1 ) { $ level = 1 ; } else if ( $ level > 9 ) { $ level = 9 ; } $ this -> compressionLevel = $ level ; } | Set the compression level |
13,788 | protected function gcCycle ( ) { $ pattern = $ this -> getCachePath ( ) . DIRECTORY_SEPARATOR . $ this -> prefix . '_*' ; $ list = glob ( $ pattern ) ; if ( $ list === false ) { trigger_error ( 'Garbage collection failure' ) ; return ; } if ( empty ( $ list ) ) { return ; } $ current = time ( ) ; foreach ( $ list as $ ... | Run the garbage collection cycle |
13,789 | public function canView ( GroupableInterface $ media , TokenInterface $ token ) : bool { $ user = $ token -> getUser ( ) ; if ( 0 == count ( $ media -> getGroups ( ) ) ) { return true ; } return parent :: canView ( $ media , $ token ) ; } | Override view handler if this is not grouped allow access . |
13,790 | public function onPreSetData ( FormEvent $ event ) { $ form = $ event -> getForm ( ) ; $ item = $ event -> getData ( ) ; foreach ( $ this -> fields as $ field ) { list ( $ name , $ type , $ options ) = $ field ; if ( null !== $ item ) { $ options = array_replace ( $ options , $ this -> itemHelper -> getFormOptions ( $ ... | Form pre set data event handler . |
13,791 | public function validatePreset ( Preset $ preset ) { foreach ( $ preset -> getOptions ( ) as $ key => $ value ) { if ( ! isset ( $ this -> handbrake_conversion [ $ key ] ) ) { throw new \ InvalidArgumentException ( sprintf ( "Unknown input argument {%s} in adapter {%s}." , $ key , $ this -> getKey ( ) ) ) ; } } } | Check that given keys have actual handbrake equivalents |
13,792 | public function & offsetGet ( $ key ) { if ( ! $ this -> has ( $ key ) ) return null ; return DotArray :: getReference ( $ this -> storage , $ key ) ; } | Get config through array offset |
13,793 | public function Indent ( $ code , $ spaces ) { $ indent = "" ; for ( $ i = 0 ; $ i < $ spaces ; $ i ++ ) { $ indent .= " " ; } if ( substr_count ( $ code , "\n" ) <= 1 ) return $ indent . $ code ; $ code = str_replace ( "\n" , "\n$indent" , $ code ) ; return $ code ; } | Useful to indent the output of a template . |
13,794 | public function GetTemplatePath ( $ name , $ type , $ subtype , $ dir , $ overrides_prefix = "" , $ namespace = "" ) { if ( $ namespace ) { $ namespace = strtolower ( str_replace ( array ( "\\" , "::" ) , "_" , $ namespace ) ) . "_" ; } if ( $ overrides_prefix ) { $ overrides_prefix = rtrim ( $ overrides_prefix , "_" )... | Get a php template file path based on the given parameters . |
13,795 | public function GetGenericTemplate ( $ name , $ subdir = "" ) { if ( $ subdir ) $ subdir = trim ( $ subdir , "\\/" ) . "/" ; return $ this -> templates_path . $ subdir . "{$name}.php" ; } | Get a php template file for a given file name . |
13,796 | public function GetParameterTemplate ( \ Peg \ Lib \ Definitions \ Element \ Parameter $ parameter , $ namespace = "" , $ type = "declare" ) { if ( ! $ this -> generator_name ) { throw new \ Exception ( t ( "The generator name wasn't set." ) ) ; } if ( $ namespace ) { $ namespace = str_replace ( array ( "\\" , "::" ) ,... | Retrieve the template path for parameters also checks if a valid override exists and returns that instead . |
13,797 | public function RemoveHeader ( $ header_name ) { $ header = $ this -> output_path . "includes/" . $ this -> GetHeaderNamePHP ( $ header_name ) ; $ source = $ this -> output_path . "src/" . $ this -> GetSourceNamePHP ( $ header_name ) ; if ( file_exists ( $ header ) ) unlink ( $ header ) ; if ( file_exists ( $ source ) ... | Deletes a generated header declarations file and its source file |
13,798 | public function AddHeader ( $ header_name , & $ content , $ subdir = "includes" ) { if ( $ subdir ) { $ subdir = trim ( $ subdir , "\\/" ) . "/" ; if ( ! file_exists ( $ this -> output_path . $ subdir ) ) \ Peg \ Lib \ Utilities \ FileSystem :: MakeDir ( $ this -> output_path . $ subdir , 0755 , true ) ; } $ header = $... | Adds or updates a header file if neccessary . |
13,799 | public function AddSource ( $ header_name , & $ content , $ subdir = "src" ) { if ( $ subdir ) { $ subdir = trim ( $ subdir , "\\/" ) . "/" ; if ( ! file_exists ( $ this -> output_path . $ subdir ) ) \ Peg \ Lib \ Utilities \ FileSystem :: MakeDir ( $ this -> output_path . $ subdir , 0755 , true ) ; } $ header = $ this... | Adds or updates a header source file if neccessary . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.