idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
1,500 | public function setProperty ( $ name , $ value ) { if ( strstr ( $ name , '.' ) ) { $ this -> setPropertyByPath ( $ name , $ value ) ; return true ; } if ( $ this -> isArray ( ) ) { $ this -> object [ $ name ] = $ value ; } else { $ this -> object -> $ name = $ value ; } return true ; } | Set Property . |
1,501 | protected function setPropertyByPath ( $ path , $ value ) { $ path = explode ( '.' , $ path ) ; $ root = $ path [ 0 ] ; unset ( $ path [ 0 ] ) ; $ array = ( $ this -> hasProperty ( $ root ) ? $ this -> getProperty ( $ root ) : [ ] ) ; $ pointer = & $ array ; foreach ( $ path as $ part ) { if ( ! isset ( $ pointer [ $ p... | Set a property by looping through . |
1,502 | public function unsetProperty ( $ name ) { if ( ! $ this -> hasProperty ( $ name ) ) { return false ; } if ( strstr ( $ name , '.' ) ) { try { $ path = explode ( '.' , $ name ) ; $ root = $ path [ 0 ] ; unset ( $ path [ 0 ] ) ; $ array = ( $ this -> hasProperty ( $ root ) ? $ this -> getProperty ( $ root ) : [ ] ) ; $ ... | Unset Property . |
1,503 | public function resolveArrayPath ( $ path ) { $ path = explode ( '.' , $ this -> escape ( $ path ) ) ; $ root = $ path [ 0 ] ; unset ( $ path [ 0 ] ) ; $ arrayPath = '["' . implode ( '"]["' , $ path ) . '"]' ; $ arrayBracket = '->' ; $ arrayBracketEnd = '' ; if ( $ this -> isArray ( ) ) { $ arrayBracket = '["' ; $ arra... | Resolve punctuation format and return path . |
1,504 | public function loopThrough ( Closure $ callable ) { $ reference = $ this -> getReference ( ) ; if ( is_null ( $ reference ) ) { $ reference = $ this -> object ; } $ this -> loop ( $ reference , $ callable ) ; } | Loop through the stored data . |
1,505 | protected function loop ( $ data , Closure $ callable ) { if ( ! is_array ( $ data ) && ! is_object ( $ data ) ) { return ; } foreach ( $ data as $ key => $ value ) { call_user_func_array ( $ callable , [ $ key , $ value ] ) ; } } | Loop through the given data and call the given function . |
1,506 | protected function unsetNullRecursively ( $ data , $ reference = null ) { if ( is_null ( $ reference ) ) { $ reference = $ data ; } $ this -> loop ( $ reference , function ( $ key , $ value ) use ( & $ data ) { if ( is_array ( $ data ) ) { if ( is_null ( $ value ) ) { unset ( $ data [ $ key ] ) ; } else { $ data [ $ ke... | Unset null properties and keys of the given data . |
1,507 | public function prepareWizardData ( ) { $ cacheKey = 'property-wizard' . md5 ( implode ( ':' , $ this -> handlersList ) ) ; $ data = Yii :: $ app -> cache -> get ( $ cacheKey ) ; if ( false === $ data ) { $ query = ( new Query ( ) ) -> from ( PropertyHandlers :: tableName ( ) ) -> indexBy ( 'id' ) -> select ( 'class_na... | Prepares json string to use in js property creation wizard |
1,508 | public function handle ( ) { if ( ! $ this -> confirm ( 'Set up DB creds now? [y|N]' ) ) { return ; } $ connected = false ; while ( ! $ connected ) { $ host = $ this -> askDatabaseHost ( ) ; $ name = $ this -> askDatabaseName ( ) ; $ user = $ this -> askDatabaseUsername ( ) ; $ password = $ this -> askDatabasePassword ... | Handle the Command |
1,509 | public function stats ( ) { return new Query \ Stats ( $ this -> mongo , $ this -> entity , $ this -> ref , $ this -> dateRange ) ; } | Query daily or monthly statistics . |
1,510 | public function dimension ( $ name = null , $ value = null ) { $ query = new Query \ Dimensions ( $ this -> mongo , $ this -> entity , $ this -> ref , $ this -> dateRange ) ; if ( ! empty ( $ name ) ) { if ( ! empty ( $ value ) ) { $ query -> setDimension ( $ name , $ value ) ; } else { $ query -> setDimension ( $ name... | Query the dimensions . |
1,511 | public function discard ( $ discard = null ) { if ( func_num_args ( ) === 0 ) { return $ this -> _data [ 'discard' ] ; } return $ this -> _data [ 'discard' ] = ( boolean ) $ discard ; } | Set whether or not this is a session cookie . |
1,512 | public function matches ( $ url ) { $ infos = parse_url ( $ url ) ; if ( $ this -> expired ( ) ) { return false ; } if ( ! $ this -> matchesScheme ( $ infos [ 'scheme' ] ) ) { return false ; } if ( ! $ this -> matchesDomain ( $ infos [ 'host' ] ) ) { return false ; } return $ this -> matchesPath ( $ infos [ 'path' ] ) ... | Checks if a scheme domain and path match the Cookie ones . |
1,513 | public function matchesPath ( $ path ) { if ( $ this -> _data [ 'path' ] === '/' || $ this -> _data [ 'path' ] === $ path ) { return true ; } if ( strpos ( $ path , $ this -> _data [ 'path' ] ) !== 0 ) { return false ; } if ( substr ( $ this -> _data [ 'path' ] , - 1 , 1 ) === '/' ) { return true ; } return substr ( $ ... | Checks if a path match the Cookie path . |
1,514 | public function matchesScheme ( $ scheme ) { $ scheme = strtolower ( $ scheme ) ; $ secure = $ this -> _data [ 'secure' ] ; return ( $ secure && $ scheme === 'https' ) || ( ! $ secure && $ scheme === 'http' ) ; } | Checks if a domain match the Cookie scheme . |
1,515 | public function expired ( $ onSessionExpires = false ) { if ( ! $ this -> _data [ 'expires' ] && $ onSessionExpires ) { return true ; } return $ this -> _data [ 'expires' ] < time ( ) && $ this -> _data [ 'expires' ] ; } | Checks if the Cookie expired . |
1,516 | public function toString ( ) { $ parts = [ ] ; $ data = $ this -> data ( ) ; $ parts [ ] = $ data [ 'name' ] . '=' . rawurlencode ( $ data [ 'value' ] ) ; if ( $ data [ 'domain' ] ) { $ parts [ ] = 'Domain=' . $ data [ 'domain' ] ; } if ( $ data [ 'path' ] ) { $ parts [ ] = 'Path=' . $ data [ 'path' ] ; } if ( isset ( ... | Return a Set - Cookie string representation of a Cookie . |
1,517 | public static function fromString ( $ value ) { $ parts = array_filter ( array_map ( 'trim' , explode ( ';' , $ value ) ) ) ; if ( empty ( $ parts ) || ! strpos ( $ parts [ 0 ] , '=' ) ) { return [ ] ; } $ config = [ ] ; $ pieces = explode ( '=' , array_shift ( $ parts ) , 2 ) ; if ( count ( $ pieces ) !== 2 ) { return... | Create a new Cookie object from a Set - Cookie header value |
1,518 | public static function isValidTimeStamp ( $ timestamp ) { return ( ( string ) ( integer ) $ timestamp === ( string ) $ timestamp ) && $ timestamp <= PHP_INT_MAX && $ timestamp >= ~ PHP_INT_MAX ; } | Checks if a timestamp is valid . |
1,519 | public static function invalidValue ( $ type , $ value ) { if ( is_object ( $ value ) ) { $ value = get_class ( $ value ) ; } elseif ( is_bool ( $ value ) || is_null ( $ value ) ) { $ value = var_export ( $ value , true ) ; } return new self ( sprintf ( 'The type "%s" does not have a name for the value "%s".' , $ type ... | Creates a new exception for a value that is not valid for a type |
1,520 | protected function showMessage ( $ message , $ in_mode = self :: ALL , $ params = NULL ) { if ( isset ( $ params ) && is_array ( $ params ) ) { $ color_codes = '' ; $ tabs = '' ; foreach ( $ params as $ key => $ value ) { switch ( $ key ) { case 'foreground' : { $ color_codes .= "\033[" . $ this -> _foreground_colors [... | Print a message on the console . |
1,521 | protected function setNewParam ( $ short_param_name , $ long_param_name , $ help_string , $ need_second_param , $ is_required ) { foreach ( $ this -> _shell_common_params as $ param ) { if ( ( $ short_param_name == $ param [ 'short_param_name' ] ) || ( $ long_param_name == $ param [ 'long_param_name' ] ) ) { throw new ... | Set a new exec param . |
1,522 | protected function parseParams ( ) { $ this -> params [ 'parsed_params' ] = array ( ) ; foreach ( $ this -> _shell_common_params as $ common_param ) { $ value = false ; foreach ( $ this -> command_options as $ option ) { if ( $ option [ 0 ] === $ common_param [ 'short_param_name' ] || $ option [ 0 ] === $ common_param ... | Parse the input arguments and store them in a class property for later usage . |
1,523 | public function _updateContentType ( ) { unset ( $ this -> _headers [ 'Content-Type' ] ) ; $ suffix = '' ; if ( $ this -> isMultipart ( ) ) { $ suffix = '; boundary=' . $ this -> boundary ( ) ; } elseif ( $ this -> _charset ) { $ suffix = '; charset=' . $ this -> _charset . $ suffix ; } if ( $ this -> _mime ) { $ this ... | Update Content - Type helper |
1,524 | public function syncContentType ( ) { $ stream = reset ( $ this -> _streams ) ; if ( ! $ this -> isMultipart ( ) && $ stream ) { unset ( $ this -> _headers [ 'Content-Type' ] ) ; $ this -> mime ( $ stream -> mime ( ) ) ; $ this -> charset ( $ stream -> charset ( ) ) ; unset ( $ this -> _headers [ 'Content-Transfer-Enco... | Sync Content - Type helper . |
1,525 | protected function _headers ( $ options , $ mime , $ charset , $ encoding , $ length ) { $ headers = ! empty ( $ options [ 'headers' ] ) ? $ options [ 'headers' ] : [ ] ; if ( ! empty ( $ options [ 'disposition' ] ) ) { $ parts = [ $ options [ 'disposition' ] ] ; foreach ( [ 'name' , 'filename' ] as $ name ) { if ( ! e... | Extract headers form streams options . |
1,526 | public function currentCallback ( CallbackIterator $ iterator ) { $ clientFilename = $ this -> fileNames [ $ iterator -> key ( ) ] ; $ filename = $ this -> directory . DIRECTORY_SEPARATOR . $ clientFilename ; $ fileObject = new ValueObject ( file_get_contents ( $ filename ) ) ; $ fileObject -> setProperty ( 'filename' ... | Returns a file object . |
1,527 | static function isValidMId ( $ vMId ) { $ bRet = false ; if ( is_array ( $ vMId ) && count ( $ vMId ) > 0 ) { $ bRet = true ; foreach ( $ vMId as $ vItem ) { if ( ! CDId :: getInstance ( ) -> isValidId ( $ vItem ) ) { $ bRet = false ; break ; } } } else { $ bRet = CDId :: getInstance ( ) -> isValidId ( intval ( $ vMId ... | check if a mid is valid |
1,528 | static function createMId ( $ nCenter = 0 , $ nNode = 0 , $ sSource = null , & $ arrData = null ) { return CDId :: getInstance ( ) -> createId ( $ nCenter , $ nNode , $ sSource , $ arrData ) ; } | create a new mid |
1,529 | public function createNewToken ( $ captcha = null , $ answer = null , $ expire = 300 ) { if ( ( null === $ captcha ) || ( null === $ answer ) ) { $ captcha = $ this -> generateEquation ( ) ; $ answer = $ this -> evaluateEquation ( $ captcha ) ; } $ this -> token = [ 'captcha' => $ captcha , 'answer' => $ answer , 'expi... | Set the token of the CAPTCHA form element |
1,530 | public function setLabel ( $ label ) { parent :: setLabel ( $ label ) ; if ( isset ( $ this -> token [ 'captcha' ] ) ) { if ( ( strpos ( $ this -> token [ 'captcha' ] , '<img' ) === false ) && ( ( strpos ( $ this -> token [ 'captcha' ] , ' + ' ) !== false ) || ( strpos ( $ this -> token [ 'captcha' ] , ' - ' ) !== fals... | Set the label of the captcha form element |
1,531 | protected function generateEquation ( ) { $ ops = [ ' + ' , ' - ' , ' * ' , ' / ' ] ; $ equation = null ; $ rand1 = rand ( 1 , 10 ) ; $ rand2 = rand ( 1 , 10 ) ; $ op = $ ops [ rand ( 0 , 3 ) ] ; if ( $ op == ' / ' ) { $ mod = ( $ rand2 > $ rand1 ) ? $ rand2 % $ rand1 : $ rand1 % $ rand2 ; while ( $ mod != 0 ) { $ rand... | Randomly generate a simple basic equation |
1,532 | protected function calculateFirstAndLastPage ( ) { $ delta = \ floor ( $ this -> maximumNumberOfLinks / 2 ) ; $ firstPage = $ this -> currentPage - $ delta ; $ lastPage = $ this -> currentPage + $ delta + ( $ this -> maximumNumberOfLinks % 2 === 0 ? 1 : 0 ) ; if ( $ firstPage < 1 ) { $ lastPage -= $ firstPage - 1 ; } i... | calculates the first and last page to show |
1,533 | protected function getNumberOfPages ( ) { $ numberOfPages = \ ceil ( $ this -> totalCount / $ this -> itemsPerPage ) ; if ( $ this -> maximumNumberOfLinks > $ numberOfPages ) { return $ numberOfPages ; } return $ numberOfPages ; } | calculates the number of pages |
1,534 | protected function getPageArray ( ) { $ range = \ range ( $ this -> firstPage , $ this -> lastPage ) ; $ pageArray = [ ] ; foreach ( $ range as $ page ) { $ pageArray [ ] = [ 'page' => $ page , 'label' => $ page , 'type' => 'page' ] ; } return $ pageArray ; } | get an array of pages to display |
1,535 | protected function addItemToTheStartOfPageArray ( $ pageArray , $ page , $ type ) { array_unshift ( $ pageArray , [ 'page' => $ page , 'label' => $ this -> paginationConfig [ 'labels' ] [ $ type ] , 'type' => $ type ] ) ; return $ pageArray ; } | add a item to the start of the page array |
1,536 | protected function addItemToTheEndOfPageArray ( $ pageArray , $ page , $ type ) { $ pageArray [ ] = [ 'page' => $ page , 'label' => $ this -> paginationConfig [ 'labels' ] [ $ type ] , 'type' => $ type ] ; return $ pageArray ; } | add a item to the end of the page array |
1,537 | public function getOptions ( ) { $ options = [ ] ; foreach ( $ this -> childNodes as $ child ) { if ( $ child instanceof Option ) { $ options [ ] = $ child ; } } return $ options ; } | Get option elements |
1,538 | public function get ( ) { if ( Cache :: has ( $ this -> getCacheKey ( ) ) ) return Cache :: get ( $ this -> getCacheKey ( ) ) ; return $ this -> create ( ) ; } | Get the Token |
1,539 | public function check ( $ token ) { if ( ! Cache :: has ( $ this -> getCacheKey ( ) ) ) return false ; return Cache :: get ( $ this -> getCacheKey ( ) ) === $ token ; } | Check the token |
1,540 | protected function getCacheKey ( ) { $ model = new \ ReflectionClass ( $ this -> model ) ; $ namespace = Str :: slug ( $ model -> getNamespaceName ( ) ) ; $ class = Str :: slug ( $ model -> getShortName ( ) ) ; $ type = Str :: slug ( $ this -> type ) ; $ key = $ this -> model -> getKey ( ) ; if ( empty ( $ key ) ) thro... | Get the cache key for save the token |
1,541 | protected function create ( ) { $ token = $ this -> generateTokenString ( ) ; Cache :: put ( $ this -> getCacheKey ( ) , $ token , $ this -> expire_in ) ; return $ token ; } | Create a new token and save as cache var |
1,542 | public function query ( $ method , $ pattern , $ callback ) { $ route = new Route ( $ pattern , $ callback , $ method ) ; $ this [ 'router' ] -> addRoute ( $ route ) ; return $ route ; } | Creates a route for a request . |
1,543 | public function run ( ) { $ request = Request :: createFromGlobals ( ) ; $ response = $ this -> handle ( $ request ) ; $ response -> send ( ) ; $ this -> invokeFinish ( [ ] , [ $ this , $ request , $ response ] ) ; } | Creates the request from globals handles it and returns the response . |
1,544 | public function addScanner ( $ languageName , $ scanner , $ langDescription ) { $ dummy = $ scanner === null ; $ d = array ( ) ; $ insert = array ( 'scanner' => $ scanner , 'description' => $ langDescription ) ; if ( ! is_array ( $ languageName ) ) { $ languageName = array ( $ languageName ) ; } foreach ( $ languageNam... | Adds a scanner into the table or overwrites an existing scanner . |
1,545 | public function removeScanner ( $ languageName ) { if ( is_array ( $ languageName ) ) { foreach ( $ languageName as $ l ) { unset ( $ this -> lookupTable [ $ l ] ) ; $ this -> unsetDescription ( $ l ) ; } } else { $ this -> unsetDescription ( $ languageName ) ; unset ( $ this -> lookupTable [ $ languageName ] ) ; } } | Removes a scanner from the table |
1,546 | private function getScannerArray ( $ languageName , $ default = true ) { $ g = null ; if ( array_key_exists ( $ languageName , $ this -> lookupTable ) ) { $ g = $ this -> lookupTable [ $ languageName ] ; } elseif ( $ this -> defaultScanner !== null && $ default === true ) { $ g = $ this -> lookupTable [ $ this -> defau... | Method which retrives the desired scanner array and recursively settles the include dependencies while doing so . |
1,547 | public function getScanner ( $ languageName , $ default = true , $ instance = true ) { $ g = $ this -> getScannerArray ( $ languageName , $ default ) ; if ( $ g !== false ) { return $ instance ? new $ g [ 'scanner' ] : $ g [ 'scanner' ] ; } return null ; } | Returns a scanner for a language |
1,548 | public function addAction ( ) { $ parent = $ this -> params ( ) -> fromRoute ( 'parent' ) ; if ( ! is_numeric ( $ parent ) ) { $ this -> flashMessenger ( ) -> addMessage ( $ this -> scTranslate ( 'The category location was not specified.' ) ) ; return $ this -> redirect ( ) -> toRoute ( 'sc-admin/content-manager' ) -> ... | Add Category . |
1,549 | public function editAction ( ) { $ id = $ this -> params ( ) -> fromRoute ( 'id' ) ; if ( ! is_numeric ( $ id ) ) { $ this -> flashMessenger ( ) -> addMessage ( $ this -> scTranslate ( 'The category ID was not specified.' ) ) ; return $ this -> redirect ( ) -> toRoute ( 'sc-admin/content-manager' ) -> setStatusCode ( 3... | Edit Category . |
1,550 | public function indexAction ( ) { $ visibilityService = $ this -> getVisibilityService ( ) ; $ options = $ visibilityService -> getOptions ( ) ; $ widgetId = $ options -> getWidgetId ( ) ; if ( ! $ widgetId ) { $ this -> flashMessenger ( ) -> addMessage ( $ this -> scTranslate ( 'The widget identifier was not specified... | Show content list with widget visibility options . |
1,551 | public function getErrorMessages ( FormInterface $ form , bool $ useLabels = false , array $ errors = [ ] ) : array { if ( $ form -> count ( ) > 0 ) { foreach ( $ form -> all ( ) as $ child ) { if ( ! $ child -> isValid ( ) ) { $ errors = $ this -> getErrorMessages ( $ child , $ useLabels , $ errors ) ; } } } foreach (... | Returns an array with form fields errors |
1,552 | protected function getErrorFormLabel ( FormInterface $ form ) : array { $ vars = $ form -> createView ( ) -> vars ; $ label = $ vars [ 'label' ] ; $ translationDomain = $ vars [ 'translation_domain' ] ; $ result = array ( 'label' => $ label , 'domain' => $ translationDomain , ) ; if ( empty ( $ label ) ) { if ( $ form ... | Returns first label for field with error |
1,553 | public static function applicablePropertyModelId ( $ class , $ forceRefresh = false ) { if ( true === method_exists ( $ class , 'getApplicableClass' ) ) { $ modelClass = call_user_func ( [ $ class , 'getApplicableClass' ] ) ; } else { $ modelClass = is_string ( $ class ) ? $ class : get_class ( $ class ) ; } self :: re... | Returns id of property_group_models record for requested classname |
1,554 | public static function classNameForApplicablePropertyModelId ( $ id , $ forceRefresh = false ) { self :: retrieveApplicablePropertyModels ( $ forceRefresh ) ; return array_search ( $ id , self :: $ applicablePropertyModels , true ) ; } | Returns class name of Model for which property or property_group model record is associated |
1,555 | public static function generateCacheKey ( $ models , $ postfix = 'properties' ) { $ ids = ArrayHelper :: getColumn ( $ models , 'id' , false ) ; sort ( $ ids ) ; $ first = reset ( $ models ) ; return $ first :: tableName ( ) . ':' . implode ( ',' , $ ids ) . "-$postfix" ; } | Generates cache key based on models array model table name and postfix |
1,556 | public static function getAvailablePropertyGroupsList ( $ className ) { $ applicablePropertyModelId = PropertiesHelper :: applicablePropertyModelId ( $ className ) ; $ availableGroups = Yii :: $ app -> cache -> lazy ( function ( ) use ( $ applicablePropertyModelId ) { return ArrayHelper :: map ( PropertyGroup :: find (... | Get available property groups by class name . |
1,557 | public function match ( GenericRequest $ request ) { Utils :: reset ( ) ; $ handlers = $ this -> getHandlers ( ) ; $ matchResult = WurflConstants :: NO_MATCH ; foreach ( $ handlers as $ handler ) { $ handler -> setLogger ( $ this -> logger ) ; if ( $ handler -> canHandle ( $ request -> getUserAgentNormalized ( ) ) ) { ... | Return the the device id for the request |
1,558 | public function persistData ( ) { $ handlers = $ this -> getHandlers ( ) ; foreach ( $ handlers as $ handler ) { $ handler -> setLogger ( $ this -> logger ) ; $ handler -> persistData ( ) ; } } | Save the data from each \ Wurfl \ Handlers \ AbstractHandler |
1,559 | public function create ( $ operation ) { if ( ! is_string ( $ operation ) ) { throw new \ LogicException ( "Provided manipulation name {$operation} is not a string!" ) ; } $ operation = str_replace ( '-' , ' ' , $ operation ) ; $ operation = strtolower ( $ operation ) ; $ operation = ucwords ( $ operation ) ; $ operati... | Creates manipulation instance |
1,560 | public function scopeOfOwner ( Builder $ builder , Model $ owner ) : Builder { return $ builder -> where ( 'owner_type' , $ owner -> getMorphClass ( ) ) -> where ( 'owner_id' , $ owner -> getKey ( ) ) ; } | Get tenants of the given owner . |
1,561 | protected function getFilters ( $ path , AssetInterface $ asset ) { $ config = $ this -> getConfig ( ) ; if ( ! empty ( $ config [ $ path ] ) ) { return $ config [ $ path ] ; } if ( ! empty ( $ asset -> mimetype ) && ! empty ( $ config [ $ asset -> mimetype ] ) ) { return $ config [ $ asset -> mimetype ] ; } $ extensio... | Get the filters from config based on path mimetype or extension . |
1,562 | protected function setFilter ( $ filter , AssetInterface $ asset ) { if ( is_null ( $ filter ) ) { return ; } if ( ! empty ( $ filter [ 'filter' ] ) ) { $ this -> ensureByFilter ( $ asset , $ filter [ 'filter' ] ) ; return ; } if ( ! empty ( $ filter [ 'service' ] ) ) { $ this -> ensureByService ( $ asset , $ filter [ ... | Set the filter by filter or service |
1,563 | public function index ( Request $ request ) { $ referrerDomain = parse_url ( $ request -> server ( 'HTTP_REFERER' ) , PHP_URL_HOST ) ; if ( $ referrerDomain !== $ this -> config -> get ( 'vanilla-integration.forum_domain' ) ) { return app ( ) -> abort ( 404 ) ; } if ( class_exists ( 'Debugbar' ) ) { \ Debugbar :: disab... | Connect method . It s returning JSONP response |
1,564 | public static function convertToUTF8 ( $ str , $ config , $ context ) { $ encoding = $ config -> get ( 'Core.Encoding' ) ; if ( $ encoding === 'utf-8' ) return $ str ; static $ iconv = null ; if ( $ iconv === null ) $ iconv = function_exists ( 'iconv' ) ; set_error_handler ( array ( 'HTMLPurifier_Encoder' , 'muteErrorH... | Converts a string to UTF - 8 based on configuration . |
1,565 | public function all ( $ locale = null ) { if ( ! $ locale ) { $ locale = $ this -> getLocale ( ) ; } $ this -> load ( $ locale ) ; $ translations = collect ( [ ] ) ; foreach ( $ this -> languages [ $ locale ] as $ key => $ arg ) { $ translations -> put ( $ key , $ arg [ 'value' ] ) ; } return $ translations ; } | Get all available translations |
1,566 | public function load ( $ locale ) { if ( $ this -> isLoaded ( $ locale ) ) { return ; } $ this -> languages [ $ locale ] = $ this -> handler -> load ( $ locale ) ; } | Load the specified language . |
1,567 | protected function finalRender ( $ debug_data ) { parent :: finalRender ( $ debug_data ) ; $ url = \ Sifo \ Urls :: getInstance ( ) -> getUrlConfig ( ) ; echo '[INFO] Script debug properly saved. You can check it out at: ' . $ url [ 'sifo_debug_analyzer' ] . '?execution_key=' . \ Sifo \ Debug :: getExecutionKey ( ) . P... | Override method in order to show a message with a link to the Sifo Debug Analyzer . |
1,568 | function publish ( $ id , $ previous ) { $ this -> requestDecorator -> setId ( $ id . '/published' ) ; $ this -> requestDecorator -> addHeader ( 'X-Contentful-Version' , $ previous [ 'sys' ] [ 'version' ] ) ; $ result = $ this -> client -> put ( $ this -> requestDecorator -> makeResource ( ) , $ this -> requestDecorato... | Publish a record . |
1,569 | function unpublish ( $ id , $ previous ) { $ this -> requestDecorator -> setId ( $ id . '/published' ) ; $ this -> requestDecorator -> addHeader ( 'X-Contentful-Version' , $ previous [ 'sys' ] [ 'version' ] ) ; $ result = $ this -> client -> delete ( $ this -> requestDecorator -> makeResource ( ) , $ this -> requestDec... | Unublish a record . |
1,570 | public function add ( $ policyName , \ Psecio \ PropAuth \ Policy $ policy ) { $ this -> policies [ $ policyName ] = $ policy ; return $ this ; } | Add a new policy to the current set with the given key name |
1,571 | public function nextIs ( $ tokenName , $ ignoreWhitespace = false ) { $ i = $ this -> index + 1 ; $ len = count ( $ this -> tokens ) ; while ( $ i < $ len ) { $ tok = $ this -> tokens [ $ i ] [ 0 ] ; if ( $ ignoreWhitespace && $ tok === 'WHITESPACE' ) { $ i ++ ; } else { return $ tok === $ tokenName ; } } return false ... | Returns true if the next token is the given token name optionally skipping whitespace |
1,572 | public function nextSequence ( $ sequence , $ ignore = array ( ) ) { $ i = $ this -> index + 1 ; $ len = count ( $ this -> tokens ) ; $ seqLen = count ( $ sequence ) ; $ seq = 0 ; $ seqStart = 0 ; while ( $ i < $ len ) { $ tok = $ this -> tokens [ $ i ] [ 0 ] ; if ( $ tok === $ sequence [ $ seq ] ) { if ( $ seq === 0 )... | Returns the index of the next match of the sequence of tokens given optionally ignoring ertain tokens |
1,573 | public function nextOf ( $ tokenNames ) { $ i = $ this -> index + 1 ; $ len = count ( $ this -> tokens ) ; while ( $ i < $ len ) { $ tok = $ this -> tokens [ $ i ] [ 0 ] ; if ( in_array ( $ tok , $ tokenNames ) ) { return $ tok ; } $ i ++ ; } return null ; } | Returns the first token which occurs out of the set of given tokens |
1,574 | public function nextOfType ( $ tokenName ) { $ i = $ this -> index + 1 ; $ len = count ( $ this -> tokens ) ; while ( $ i < $ len ) { $ tok = $ this -> tokens [ $ i ] [ 0 ] ; if ( $ tok === $ tokenName ) { return $ i ; } $ i ++ ; } return $ len ; } | Returns the index of the next token with the given token name |
1,575 | private function parseRule ( ) { $ newToken = $ this -> tokens [ $ this -> index ] ; $ set = false ; if ( $ this -> index > 0 ) { $ prevToken = & $ this -> tokens [ $ this -> index - 1 ] ; $ prevTokenType = & $ prevToken [ 0 ] ; $ prevTokenText = & $ prevToken [ 1 ] ; $ concat = false ; $ map = array ( 'DOT' => 'CLASS_... | Parses a selector rule |
1,576 | private function cleanup ( ) { foreach ( $ this -> tokens as $ i => $ t ) { if ( $ t [ 0 ] === self :: $ deleteToken ) { unset ( $ this -> tokens [ $ i ] ) ; } } $ this -> tokens = array_values ( $ this -> tokens ) ; } | Cleans up the token stream by deleting any tokens marked for deletion and makes sure the array is continuous afterwards . |
1,577 | public function interpString ( $ m ) { $ patterns = array ( 'interp' => '/(?<!\\$)\\$\\{/' ) ; $ start = $ this -> pos ( ) ; if ( preg_match ( '/^"""/' , $ m [ 0 ] ) ) { $ patterns [ 'term' ] = '/"""/' ; $ this -> posShift ( 3 ) ; } else { assert ( preg_match ( '/^"/' , $ m [ 0 ] ) ) ; $ patterns [ 'term' ] = '/"/' ; $... | string interpolation is complex and it nests so we do that in here |
1,578 | public function brace ( $ m ) { if ( $ m [ 0 ] === '{' ) { $ this -> braceStack ++ ; } elseif ( $ m [ 0 ] === '}' ) { if ( $ this -> braceStack <= 0 ) { return true ; } $ this -> braceStack -- ; } else { assert ( 0 ) ; } $ this -> record ( $ m [ 0 ] , null ) ; $ this -> posShift ( strlen ( $ m [ 0 ] ) ) ; } | this is for interpolated code the top - level scanner doesn t bind to this |
1,579 | public function get ( $ name ) { if ( isset ( $ this -> fields [ $ name ] ) ) { return $ this -> fields [ $ name ] ; } throw new FieldException ( "Fielder doesn't have [$name] field registered." ) ; } | Get registered field . |
1,580 | public function make ( $ class , $ type , $ slug , $ arguments = [ ] ) { $ field = $ this -> container -> make ( $ class ) ; $ field -> setType ( $ type ) -> setSlug ( $ slug ) -> setArguments ( $ arguments ) -> boot ( ) ; return $ field ; } | Creates field instance . |
1,581 | public function output ( $ view , $ data = [ ] ) { $ path = $ this -> processOutput ( $ view , $ data ) ; $ content = file_get_contents ( $ path ) ; @ unlink ( $ path ) ; return $ content ; } | Get pdf output for the view . |
1,582 | protected function processOutput ( $ view , $ data = [ ] ) { $ name = $ this -> generateFileName ( ) ; $ path = __DIR__ . DIRECTORY_SEPARATOR . "{$name}" ; file_put_contents ( $ path , $ this -> generateView ( $ view , $ data ) ) ; $ this -> getPhantomProcess ( $ path ) -> setTimeout ( 0 ) -> mustRun ( ) ; return $ pat... | Process pdf output for the view . |
1,583 | public function download ( $ view , $ data = [ ] , $ name = 'download' ) { $ path = $ this -> processOutput ( $ view , $ data ) ; return $ this -> responseDownload ( $ path , $ name ) ; } | Download generated pdf file . |
1,584 | protected function responseDownload ( $ path , $ name ) { $ response = new Response ( file_get_contents ( $ path ) , 200 , [ 'Content-Type' => 'application/pdf' , 'Content-Description' => 'File Transfer' , 'Content-Disposition' => 'attachment; filename="' . $ name . '.pdf"' , 'Content-Transfer-Encoding' => 'binary' ] )... | Http response to download the pdf . |
1,585 | public function stream ( $ view , $ data = [ ] ) { $ path = $ this -> processOutput ( $ view , $ data ) ; return $ this -> responseStream ( $ path ) ; } | View pdf in the browser . |
1,586 | protected function responseStream ( $ path ) { $ response = new Response ( file_get_contents ( $ path ) , 200 , [ 'Content-type' => 'application/pdf' , 'Content-Transfer-Encoding' => 'binary' ] ) ; @ unlink ( $ path ) ; return $ response -> send ( ) ; } | Http response to stream pdf in the browser . |
1,587 | protected function getSystem ( ) { $ osName = strtolower ( php_uname ( ) ) ; if ( $ this -> contains ( $ osName , 'darwin' ) ) { return 'macosx' ; } elseif ( $ this -> contains ( $ osName , 'win' ) ) { return 'windows' ; } elseif ( $ this -> contains ( $ osName , 'linux' ) ) { return PHP_INT_SIZE === 4 ? 'linux-i686' :... | Get the operating system name for the current platform . |
1,588 | protected function generateView ( $ view , $ data = [ ] ) { if ( is_null ( $ this -> viewPath ) ) { return $ view ; } $ twig = new Twig_Environment ( new Twig_Loader_Filesystem ( realpath ( $ this -> viewPath ) ) ) ; return $ twig -> render ( $ view , $ data ) ; } | Generate view for the pdf file . |
1,589 | protected function getConfigurationFile ( ) { if ( ! is_null ( $ this -> configPath ) ) { return realpath ( $ this -> configPath ) ; } elseif ( function_exists ( 'base_path' ) and file_exists ( $ phantomConfiguration = base_path ( ) . DIRECTORY_SEPARATOR . 'SunPdf.js' ) ) { return realpath ( $ phantomConfiguration ) ; ... | Get PhantomJS configuration file . |
1,590 | public function isCorrectType ( $ type , $ path ) { if ( ! $ type ) { return true ; } if ( ! isset ( $ this -> typeCache [ $ path ] ) ) { $ this -> typeCache [ $ path ] = is_file ( $ path ) ? 'file' : 'dir' ; } return $ this -> typeCache [ $ path ] === $ type ; } | Checks wether an path is of the correct type dir or file |
1,591 | public function filter ( array $ contents ) { $ filtered = array ( ) ; $ this -> typeCache = array ( ) ; foreach ( $ contents as $ item ) { $ passed = true ; foreach ( $ this -> filters as $ filter ) { $ correctType = $ this -> isCorrectType ( $ filter [ 'type' ] , $ item ) ; if ( $ correctType and preg_match ( $ filte... | Filters a batch of filesystem entries |
1,592 | public static function cleanThumbnail ( ) : array { $ result = [ ] ; $ files = Finder :: findFiles ( '*' ) -> in ( self :: $ parameters [ 'thumbPath' ] ) ; foreach ( $ files as $ file ) { if ( unlink ( $ file -> getPathname ( ) ) ) { $ result [ ] = $ file -> getPathname ( ) ; } } return $ result ; } | Clean thumbnail . |
1,593 | private static function getThumbFiles ( ) : array { $ result = [ ] ; $ thumbFinder = Finder :: findFiles ( '*' ) -> in ( self :: $ parameters [ 'thumbPath' ] ) ; foreach ( $ thumbFinder as $ file ) { $ basename = $ file -> getBaseName ( ) ; $ specialDelimiter = strrpos ( $ basename , '_' ) ; $ lastDot = strrpos ( $ bas... | Get thumb files . |
1,594 | private static function getPathFiles ( array $ path ) : array { $ result = [ ] ; $ pathFinder = Finder :: findFiles ( '*' ) -> in ( $ path ) ; foreach ( $ pathFinder as $ file ) { $ result [ $ file -> getRealPath ( ) ] = $ file -> getBaseName ( ) ; } return $ result ; } | Get path files . |
1,595 | public static function synchronizeThumbnail ( array $ path ) : array { $ result = [ ] ; $ thumbFiles = self :: getThumbFiles ( ) ; $ pathFiles = self :: getPathFiles ( $ path ) ; $ diff = array_diff ( $ thumbFiles , $ pathFiles ) ; foreach ( $ diff as $ oldName => $ file ) { if ( unlink ( $ oldName ) ) { $ result [ ] =... | Synchronize thumbnail . |
1,596 | public static function getUnusedFiles ( array $ path ) : array { $ thumbFiles = self :: getThumbFiles ( ) ; $ pathFiles = self :: getPathFiles ( $ path ) ; return $ diff = array_diff ( $ pathFiles , $ thumbFiles ) ; } | Get unused files . |
1,597 | public static function isSrcPathExists ( string $ path , string $ file = null ) : bool { $ src = self :: $ parameters [ 'dir' ] . $ path . $ file ; return file_exists ( $ src ) && is_file ( $ src ) ; } | Is src path exists . |
1,598 | public static function getSrcPath ( string $ path , string $ file = null , string $ width = null , string $ height = null , array $ flags = [ ] , int $ quality = null ) : string { $ cacheName = 'getSrcPath' . $ path . $ file . $ width . $ height . implode ( $ flags ) . $ quality ; $ destination = ( self :: $ parameters... | Get src path . |
1,599 | private static function getImageFlag ( array $ flags ) : int { $ res = 0 ; foreach ( $ flags as $ flag ) { $ res |= constant ( Image :: class . '::' . $ flag ) ; } return $ res ; } | Get image flag . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.