idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
15,600
protected function getReflectionById ( $ id ) { if ( ! isset ( $ this -> classReflections [ $ id ] ) ) { $ this -> classReflections [ $ id ] = $ this -> initReflection ( $ id ) ; } return $ this -> classReflections [ $ id ] ; }
Get class reflection by ID
15,601
protected function initReflection ( $ id ) { $ normalizedId = ucfirst ( $ id ) ; $ classname = $ this -> dirForEachService ? $ normalizedId : '' ; $ classname .= $ this -> classPrefix . $ normalizedId . $ this -> classPostfix ; foreach ( $ this -> namespaces as $ namespace ) { $ class = $ namespace . '\\' . $ classname...
Initialize class reflection by ID
15,602
public function reindexAll ( ) { $ this -> tableStrategy -> setUseIdxTable ( false ) ; $ this -> beginTransaction ( ) ; try { $ this -> reindex ( ) ; $ this -> commit ( ) ; } catch ( \ Exception $ e ) { $ this -> rollBack ( ) ; throw $ e ; } return $ this ; }
Reindex data for all products
15,603
public function getKeys ( array $ domains = [ ] , array $ languages = [ ] ) : array { return array_reduce ( $ this -> getTranslations ( $ domains , $ languages ) , function ( array $ keys , Translation $ translation ) { $ keys [ ] = $ translation -> getKey ( ) ; return $ keys ; } , [ ] ) ; }
Get available keys .
15,604
public function setName ( $ name ) { $ name = str_replace ( '/' , '' , $ name ) ; $ bytes = mb_strlen ( $ name , 'latin1' ) ; if ( $ bytes <= self :: MAX_NAME_BYTES ) { return $ this -> set ( 'name' , $ name ) ; } else { throw new UnexpectedValueException ( "Container name may be max " . self :: MAX_NAME_BYTES . " byte...
Set the user name
15,605
public function setMetadata ( $ key , $ value ) { $ key = urlencode ( $ key ) ; $ value = urlencode ( $ value ) ; if ( count ( $ this -> metadataHeaders ) < self :: MAX_METADATA_HEADERS ) { if ( strlen ( $ key ) <= self :: MAX_METADATA_KEY ) { if ( strlen ( $ value ) <= self :: MAX_METADATA_VALUE ) { $ this -> metadata...
Sets a metadata header for the container which will be created .
15,606
public static function uid10 ( ) : string { $ converted = base_convert ( self :: $ hex_chars [ random_int ( 0 , 15 ) ] . uniqid ( '' , true ) . self :: $ hex_chars [ random_int ( 0 , 15 ) ] , 16 , 10 ) ; $ res = '' ; for ( $ i = floor ( log10 ( ( float ) $ converted ) / 1.7923916894983 ) ; $ i >= 0 ; -- $ i ) { $ j = 6...
Generate simple random string useful for hex names
15,607
public static function textToUidJs ( $ wrap_js_tags = true , array $ link_ids = [ ] , $ max_length = 99 , $ run_on_page_load = true , $ run_on_input_change = true ) { echo self :: uidFromTextJsFunction ( $ wrap_js_tags ) ; if ( $ link_ids ) { if ( $ wrap_js_tags ) { echo '<script>' ; } $ auto_run = $ run_on_page_load |...
Replaces non - latin chars to latin pairs with JS event handlers
15,608
public function getLangBrowserByCurrentUser ( $ forceLang = '' ) { $ allLangAvailable = $ this -> availableLanguages ( ) ; $ isLangAvailable = function ( $ langToCheck ) use ( $ allLangAvailable ) { return in_array ( $ langToCheck , $ allLangAvailable ) ; } ; if ( $ forceLang && $ isLangAvailable ( $ forceLang ) ) { re...
Return the lang by current user if it was established
15,609
public function fullNameLanguageByCurrentUserBrowser ( $ forceLang = false ) { $ lang = $ this -> getLangBrowserByCurrentUser ( $ forceLang ) ; return $ this -> langValue ( $ lang ) ; }
Return the fullName of the lang by current user .
15,610
public function trans ( $ toTranslate , $ params = [ ] , $ forceLang = '' ) { $ toTranslate = strtolower ( $ toTranslate ) ; $ this -> _getParams ( $ toTranslate , $ params ) ; $ toTranslate = trim ( $ toTranslate ) ; if ( false === strpos ( '.' , $ toTranslate ) ) { $ toTranslate .= '.' ; } list ( $ fileName , $ key )...
Return the translation word by key
15,611
private function _setParams ( $ value , $ params ) { $ strFinal = $ value ; $ key = '' ; for ( $ i = 0 ; $ i < strlen ( $ strFinal ) ; $ i ++ ) { if ( $ strFinal [ $ i ] == ':' ) { $ _a = $ i + 1 ; for ( $ j = $ _a ; $ j < strlen ( $ strFinal ) ; $ j ++ ) { $ isLastOne = ( $ j == strlen ( $ strFinal ) - 1 ) ; if ( in_a...
Set the params into the string
15,612
public function transU ( $ key , $ params = [ ] , $ forceLang = '' ) { return ucfirst ( $ this -> trans ( $ key , $ params , $ forceLang ) ) ; }
Return the translated word with the first letter in uppercase .
15,613
public function getPaginator ( $ criteria = [ ] , array $ fields = [ ] ) { $ criteriaNormalized = $ this -> normalizeCriteria ( $ criteria ) ; $ mongoCursor = $ this -> getAdapter ( ) -> find ( $ this -> getTableName ( ) , $ criteriaNormalized , $ fields ) ; if ( $ criteria instanceof Criteria ) { $ this -> applyCriter...
Fetch an items from a database and return as paginator
15,614
public function getIterator ( $ criteria = [ ] , array $ fields = [ ] ) { $ criteriaNormalized = $ this -> normalizeCriteria ( $ criteria ) ; $ mongoCursor = $ this -> getAdapter ( ) -> find ( $ this -> getTableName ( ) , $ criteriaNormalized , $ fields ) ; if ( $ criteria instanceof Criteria ) { $ this -> applyCriteri...
Fetch an items from a database and return as iterator
15,615
protected function applyCriteriaToCursor ( Criteria $ criteria , MongoCursor $ mongoCursor ) { $ sort = $ criteria -> getSortConditions ( ) ; $ offset = $ criteria -> getOffset ( ) ; $ limit = $ criteria -> getLimit ( ) ; if ( ! empty ( $ sort ) ) { $ mongoCursor -> sort ( $ sort ) ; } if ( $ offset !== null ) { $ mong...
Apply critera to Mongo cursor
15,616
protected function resolvePrimaryIdByPipeline ( array $ pipeline ) { foreach ( $ pipeline as $ stage ) { foreach ( $ stage as $ name => $ definition ) { if ( $ name === '$group' && isset ( $ definition [ '_id' ] ) ) { return ltrim ( $ definition [ '_id' ] , '$' ) ; } } } }
Resolve the primary ID by aggregation pipeline definition
15,617
public function insert ( array $ data , array $ options = [ ] ) { return $ this -> getAdapter ( ) -> insert ( $ this -> getTableName ( ) , $ data , $ options ) ; }
Insert an item into a database
15,618
public function delete ( array $ criteria = [ ] , array $ options = [ ] ) { return $ this -> getAdapter ( ) -> remove ( $ this -> getTableName ( ) , $ criteria , $ options ) ; }
Delete an items from a database
15,619
public function update ( array $ data , array $ criteria = [ ] , array $ options = [ ] ) { return $ this -> getAdapter ( ) -> update ( $ this -> getTableName ( ) , $ criteria , $ data , $ options ) ; }
Update some items of a database
15,620
public function getAdapter ( ) { if ( $ this -> _adapter === null ) { if ( $ this -> hasLocator ( ) ) { $ this -> _adapter = $ this -> getLocator ( ) -> get ( $ this -> getAdapterName ( ) ) ; } else { throw new Exceptions \ NoAdapter ( 'Nor a database adapter neither a services locator has been provided' ) ; } } return...
Get a database adapter
15,621
public function isCached ( ) { if ( $ this -> cached ) return true ; if ( ! $ this -> cacheId ) return false ; if ( ! file_exists ( $ this -> cachePath . $ this -> cacheId ) ) return false ; if ( ! ( $ mtime = filemtime ( $ this -> cachePath . $ this -> cacheId ) ) ) return false ; if ( ( $ mtime + $ this -> expire ) <...
Test to see whether the currently loaded cacheId has a valid corrosponding cache file .
15,622
protected function registerServerEvents ( array $ events ) : void { $ eventInfo = [ ] ; foreach ( $ events as $ name => $ cb ) { if ( \ is_object ( $ cb ) && \ method_exists ( $ cb , '__invoke' ) ) { $ eventInfo [ ] = [ $ name , \ get_class ( $ cb ) ] ; $ this -> server -> on ( $ name , $ cb ) ; continue ; } if ( \ is_...
register Swoole Events
15,623
protected function attachUserProcesses ( ) : void { if ( $ reloader = $ this -> createHotReloader ( ) ) { $ this -> server -> addProcess ( $ reloader ) ; } foreach ( $ this -> processCallbacks as $ name => $ callback ) { $ this -> createProcess ( $ name , $ callback ) ; } }
attach user s custom process
15,624
protected function createHotReloader ( ) { $ reload = $ this -> config [ 'auto_reload' ] ; if ( ! $ reload || ! \ function_exists ( 'inotify_init' ) ) { return false ; } $ mgr = $ this ; $ options = [ 'dirs' => $ reload , ] ; return new Process ( function ( Process $ process ) use ( $ options , $ mgr ) { $ pid = $ proc...
create code hot reload worker
15,625
protected function createListenServers ( Server $ server ) : void { $ this -> fire ( ServerEvent :: PORT_CREATE , $ this ) ; foreach ( $ this -> attachedListeners as $ name => $ cb ) { $ info = '' ; if ( $ cb instanceof \ Closure ) { $ port = $ cb ( $ server , $ this ) ; } else { $ port = $ cb -> attachTo ( $ this , $ ...
create Listen Port Servers
15,626
public function attachPort ( string $ name , $ config ) : void { if ( isset ( $ this -> attachedNames [ strtolower ( $ name ) ] ) ) { throw new \ InvalidArgumentException ( "The add listen port server [$name] has been exists!" ) ; } if ( \ is_array ( $ config ) ) { $ class = Arr :: remove ( $ config , 'listener' ) ; if...
attach add listen port to main server .
15,627
public function inactive ( ) { $ layout = view ( ) -> exists ( 'layouts.default' ) ? 'layouts.default' : 'layout' ; $ pageTitle = 'Inactive account' ; $ token = $ this -> activation -> findTokenByEmail ( session ( 'inactive_email' ) ) ; return view ( 'auth.activation.inactive' , compact ( 'layout' , 'pageTitle' , 'toke...
Display the account inactive page .
15,628
public function failed ( $ tokenString ) { $ layout = view ( ) -> exists ( 'layouts.default' ) ? 'layouts.default' : 'layout' ; $ pageTitle = 'Activation failed' ; $ token = $ this -> activation -> findToken ( $ tokenString ) ; return view ( 'auth.activation.failed' , compact ( 'layout' , 'pageTitle' , 'token' ) ) ; }
Display the page saying that activation failed .
15,629
public function parameters ( array $ parameters ) { foreach ( $ parameters as $ parameter => $ value ) { if ( property_exists ( $ this -> parameters , $ parameter ) ) { $ this -> parameters -> { $ parameter } = $ value ; } } return $ this ; }
Set parameters from given array .
15,630
protected function sendRequest ( ) { $ parameters = $ this -> parameters -> toArray ( ) ; $ parameters [ 'key' ] = $ this -> config [ 'api_key' ] ; $ response = $ this -> guzzle -> get ( $ this -> getRequestUrl ( ) , [ 'query' => $ parameters , ] ) ; return json_decode ( ( string ) $ response -> getBody ( ) ) ; }
Send a request to Google Geocoding API .
15,631
public function addFields ( $ term , $ mode = 'edit' ) { $ mode = in_array ( $ mode , [ 'add' , 'edit' ] ) ? $ mode : 'edit' ; if ( empty ( $ this -> fields ) ) { return ; } $ term = is_object ( $ term ) ? $ term : get_term ( $ term ) ; foreach ( $ this -> fields as $ field ) { if ( ! $ field ) { continue ; } $ ctn = (...
Hook building custom fields .
15,632
public function manageCustomColumn ( $ content , $ column , $ term_id ) { $ current = Request :: get ( 'taxonomy' ) ; if ( empty ( $ current ) ) { return ; } do_action ( 'ol_zeus_termhook_manage_' . $ current . '_custom_column' , $ content , $ column , $ term_id ) ; }
Hook to add custom column .
15,633
public function saveFields ( $ term_id ) { if ( ! isset ( $ term_id ) || empty ( $ term_id ) || empty ( $ this -> fields ) ) { return ; } $ slug = Request :: post ( 'taxonomy' , '' ) ; if ( empty ( $ slug ) || $ slug !== $ this -> slug ) { return ; } remove_action ( 'created_' . $ slug , [ & $ this , 'saveFields' ] ) ;...
Hook building custom fields for Post types .
15,634
public static function build ( $ id , $ contents = [ ] , $ details = [ ] ) { try { $ field = self :: getInstance ( ) ; } catch ( Exception $ e ) { throw new FieldException ( Translate :: t ( 'field.errors.class_is_not_defined' ) ) ; } $ class = get_class ( $ field ) ; $ hasid = $ field -> getModel ( ) -> getHasId ( ) ;...
Build Field component .
15,635
public function render ( $ contents = [ ] , $ details = [ ] , $ renderView = true , $ context = 'field' ) { $ contents = array_merge ( $ this -> getModel ( ) -> getContents ( ) , $ contents ) ; $ details = array_merge ( $ this -> getModel ( ) -> getDetails ( ) , $ details ) ; $ class = $ this -> getClass ( ) ; $ contex...
Render HTML component .
15,636
public function renderAssets ( ) { $ class = $ this -> getClass ( ) ; $ path = $ class [ 'resources' ] . S . 'assets' . S ; $ script = $ this -> getModel ( ) -> getScript ( ) ; $ style = $ this -> getModel ( ) -> getStyle ( ) ; $ assets = [ ] ; if ( empty ( $ script ) && empty ( $ style ) ) { return $ assets ; } if ( !...
Render assets component .
15,637
public function primaryGroup ( ) : ? Model { if ( $ this -> userPrimaryGroup !== null ) { return $ this -> userPrimaryGroup ; } $ usergroups = $ this -> usergroups ; foreach ( $ usergroups as $ id => $ usergroup ) { if ( $ usergroup -> primary ) { return $ this -> userPrimaryGroup = $ usergroup -> group ; } } return $ ...
Get users primary group
15,638
public function getActiveCages ( ) : Collection { if ( $ this -> activeCagesCollection !== null ) { return $ this -> activeCagesCollection ; } $ this -> activeCagesCollection = new Collection ( ) ; foreach ( $ this -> allCages as $ id => $ cage ) { if ( ! $ cage -> isExpired ( ) && ! $ cage -> isRemoved ( ) ) { $ this ...
Get active cages from all cages This saves a query
15,639
public function getUserFlags ( ) : array { if ( $ this -> flags !== null ) { return $ this -> flags ; } $ this -> flags = [ ] ; $ usergroups = $ this -> usergroups ; foreach ( $ usergroups as $ usergroup ) { $ group = $ usergroup -> group ; $ flags = $ group -> flags ; if ( ! empty ( $ flags ) ) { $ this -> flags = arr...
Get all user flags .
15,640
public function hasFlag ( $ flag ) : bool { if ( is_array ( $ flag ) ) { return $ this -> hasFlags ( $ flag ) ; } return in_array ( $ flag , $ this -> getUserFlags ( ) ) ; }
Check if user has flag .
15,641
public function hasFlags ( array $ flags , bool $ matchAll = false ) : bool { $ matched = false ; $ userFlags = $ this -> getUserFlags ( ) ; foreach ( $ flags as $ flag ) { if ( in_array ( $ flag , $ userFlags ) ) { if ( $ matchAll ) { $ matched = true ; continue ; } $ matched = true ; } else { if ( $ matchAll ) { retu...
Check if user has flags
15,642
public function hasGroupId ( int $ id ) : bool { $ usergroups = $ this -> usergroups ; foreach ( $ usergroups as $ index => $ usergroup ) { if ( $ usergroup -> group_id === $ id ) { return true ; } } return false ; }
Check if user has group .
15,643
public function hasCage ( string $ area , int $ level = 0 , bool $ activeOnly = true ) : ? Model { $ cages = $ activeOnly ? $ this -> getActiveCages ( ) : $ this -> allCages ; foreach ( $ cages as $ index => $ cage ) { if ( $ cage -> area === $ area && $ cage -> level >= $ level ) { return $ cage ; } } return null ; }
Check if user has cage .
15,644
public function validateUri ( $ uri ) { $ query = http_build_query ( array_merge ( $ this -> getOptions ( ) -> buildOptions ( ) , array ( 'uri' => $ uri ) ) ) ; $ context = stream_context_create ( array ( 'http' => array ( 'method' => 'GET' , 'header' => 'User-Agent: HTMLValidator' , ) ) ) ; $ data = $ this -> sendRequ...
Validates a given URI
15,645
public function validateFile ( $ file ) { if ( file_exists ( $ file ) !== true ) { throw new Exception ( 'File not found' ) ; } if ( is_readable ( $ file ) !== true ) { throw new Exception ( 'File not readable' ) ; } $ data = file_get_contents ( $ file ) ; if ( $ data === false ) { throw new Exception ( 'Failed get fil...
Validates the local file
15,646
public function validateFragment ( $ html ) { $ query = http_build_query ( array_merge ( $ this -> getOptions ( ) -> buildOptions ( ) , array ( 'fragment' => $ html ) ) ) ; $ context = stream_context_create ( array ( 'http' => array ( 'method' => 'POST' , 'header' => "Content-Type: application/x-www-form-urlencoded\r\n...
Validate an html string
15,647
protected function parseSOAP12Response ( $ xml ) { $ doc = new \ DOMDocument ( '1.0' , 'UTF-8' ) ; if ( $ doc -> loadXML ( $ xml ) === false ) { throw new Exception ( 'Failed load xml' ) ; } $ response = new Response ( ) ; foreach ( array ( 'uri' , 'checkedby' , 'doctype' , 'charset' ) as $ var ) { $ element = $ doc ->...
Parse an XML response from the validator
15,648
protected function getPropStats ( ) : array { $ result = [ ] ; $ failed = false ; foreach ( $ this -> proppatch -> getOperations ( ) as $ operation ) { $ tmp = $ operation -> getResult ( ) ; if ( is_integer ( $ tmp ) ) { if ( empty ( $ result [ $ tmp ] ) ) { $ result [ $ tmp ] = [ ] ; } $ result [ $ tmp ] [ ] = $ opera...
Compute propstats from patch operations and return them groupded by HTTP status code .
15,649
protected function getImage ( $ keyImg , $ sizeW , $ sizeH = false ) { $ sizeH = ( $ sizeH ) ? $ sizeH : $ sizeW ; $ local_avatars = get_user_meta ( $ this -> ID , $ keyImg , true ) ; if ( empty ( $ local_avatars [ 'full' ] ) ) { return '' ; } if ( ! array_key_exists ( $ sizeW , $ local_avatars ) ) { $ local_avatars [ ...
Get the image
15,650
private function removeImage ( $ keyImg ) { $ getImagePath = $ this -> getImagePath ( $ keyImg ) ; $ sizes = $ this -> getImageSizesToDelete ( ) ; foreach ( $ sizes as $ size ) { $ imgPath = $ getImagePath [ 'virgen' ] . "-{$size}x{$size}" . $ getImagePath [ 'ext' ] ; if ( file_exists ( $ imgPath ) ) { unlink ( $ imgPa...
Remove the image
15,651
private function getImagePath ( $ keyImg ) { $ upload_path = wp_upload_dir ( ) ; $ img = $ this -> getImage ( $ keyImg , User :: AVATAR_SIZE_ICO ) ; $ path = str_replace ( $ upload_path [ 'baseurl' ] , $ upload_path [ 'basedir' ] , $ img ) ; $ current = $ base = basename ( $ path ) ; if ( strpos ( $ base , '-' ) !== fa...
Return the base name of the img and the name of the current img .
15,652
public static function getDomainName ( string $ url ) : string { if ( isset ( self :: $ cached_url_domains [ $ url ] ) ) { return self :: $ cached_url_domains [ $ url ] ; } $ parsed_url = parse_url ( strtolower ( $ url ) ) ; $ host = $ parsed_url [ 'host' ] ?? '' ; if ( 0 === strpos ( $ host , 'www.' ) ) { $ host = sub...
Get domain name by full URL address
15,653
public static function ini ( string $ ini_file , $ environment = null ) : array { $ result = [ ] ; $ data = parse_ini_file ( $ ini_file , true ) ; if ( ! empty ( $ data [ 'environment' ] ) ) { foreach ( $ data [ 'environment' ] as $ k => $ v ) { array_key_set ( $ result , explode ( '.' , $ k ) , $ v ) ; } } unset ( $ d...
Process ini file
15,654
public function setValue ( $ value ) { NumericValidator :: validate ( $ value , "Value" ) ; $ value = Formatter :: formatToPrice ( $ value , $ this -> getCurrency ( ) ) ; $ this -> value = $ value ; return $ this ; }
amount up to N digit after the decimals separator as defined in ISO 4217 for the appropriate currency code .
15,655
public function authenticate ( GenericUserInterface $ user , $ credential ) { $ authenticationResult = $ this -> passwordManager -> validate ( $ credential , $ user -> getCredential ( ) ) ; if ( ! $ authenticationResult ) { throw new InvalidCredentialException ( ) ; } $ this -> store ( $ user -> getAttributes ( ) ) ; r...
Authenticates user with indicated credential
15,656
protected function isCompressable ( ServerRequestInterface $ request , ResponseInterface $ response ) : bool { if ( $ request -> getMethod ( ) === Http :: HEAD ) { return false ; } if ( Http :: isResponseWithoutBody ( $ response -> getStatusCode ( ) ) ) { return false ; } if ( ! $ response -> hasHeader ( 'Content-Type'...
Check if the given response payload should be compressed .
15,657
protected function findVariable ( $ i , $ escape ) { $ close = $ this -> bars [ 1 ] . $ this -> bars [ 1 ] ; if ( $ escape ) { $ close = $ close . $ this -> bars [ 1 ] ; } for ( ; substr ( $ this -> source , $ i , strlen ( $ close ) ) !== $ close ; $ i ++ ) { } return $ i + strlen ( $ close ) ; }
Since we know where the start is we need to find the end in the source
15,658
public function update ( UserPolicy $ user , PriceList $ price_list ) { if ( $ user -> canDo ( 'pricelist.price_list.edit' ) && $ user -> isAdmin ( ) ) { return true ; } return $ price_list -> user_id == user_id ( ) && $ price_list -> user_type == user_type ( ) ; }
Determine if the given user can update the given price_list .
15,659
public function destroy ( UserPolicy $ user , PriceList $ price_list ) { return $ price_list -> user_id == user_id ( ) && $ price_list -> user_type == user_type ( ) ; }
Determine if the given user can delete the given price_list .
15,660
public function index ( PriceListRequest $ request ) { $ view = $ this -> response -> theme -> listView ( ) ; if ( $ this -> response -> typeIs ( 'json' ) ) { $ function = camel_case ( 'get-' . $ view ) ; return $ this -> repository -> setPresenter ( \ Litecms \ Pricelist \ Repositories \ Presenter \ PriceListPresenter...
Display a list of price_list .
15,661
public function show ( PriceListRequest $ request , PriceList $ price_list ) { if ( $ price_list -> exists ) { $ view = 'pricelist::price_list.show' ; } else { $ view = 'pricelist::price_list.new' ; } return $ this -> response -> title ( trans ( 'app.view' ) . ' ' . trans ( 'pricelist::price_list.name' ) ) -> data ( co...
Display price_list .
15,662
public function edit ( PriceListRequest $ request , PriceList $ price_list ) { return $ this -> response -> title ( trans ( 'app.edit' ) . ' ' . trans ( 'pricelist::price_list.name' ) ) -> view ( 'pricelist::price_list.edit' , true ) -> data ( compact ( 'price_list' ) ) -> output ( ) ; }
Show price_list for editing .
15,663
public function update ( PriceListRequest $ request , PriceList $ price_list ) { try { $ attributes = $ request -> all ( ) ; $ price_list -> update ( $ attributes ) ; return $ this -> response -> message ( trans ( 'messages.success.updated' , [ 'Module' => trans ( 'pricelist::price_list.name' ) ] ) ) -> code ( 204 ) ->...
Update the price_list .
15,664
public function destroy ( PriceListRequest $ request , PriceList $ price_list ) { try { $ price_list -> delete ( ) ; return $ this -> response -> message ( trans ( 'messages.success.deleted' , [ 'Module' => trans ( 'pricelist::price_list.name' ) ] ) ) -> code ( 202 ) -> status ( 'success' ) -> url ( guard_url ( 'pricel...
Remove the price_list .
15,665
protected function getTranslations ( string $ file ) : array { return $ this -> files -> exists ( $ file ) ? ( array ) json_decode ( $ this -> files -> get ( $ file ) ) : [ ] ; }
Get an array containing all translations form a json file .
15,666
protected function put ( string $ file , array $ translations ) { $ this -> files -> put ( $ file , json_encode ( $ translations , JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT ) ) ; }
Update the json file with new object .
15,667
public function index ( FaqRequest $ request ) { $ view = $ this -> response -> theme -> listView ( ) ; if ( $ this -> response -> typeIs ( 'json' ) ) { $ function = camel_case ( 'get-' . $ view ) ; return $ this -> repository -> setPresenter ( \ Litecms \ Faq \ Repositories \ Presenter \ FaqPresenter :: class ) -> $ f...
Display a list of faq .
15,668
public function show ( FaqRequest $ request , Faq $ faq ) { if ( $ faq -> exists ) { $ view = 'faq::faq.show' ; } else { $ view = 'faq::faq.new' ; } return $ this -> response -> title ( trans ( 'app.view' ) . ' ' . trans ( 'faq::faq.name' ) ) -> data ( compact ( 'faq' ) ) -> view ( $ view , true ) -> output ( ) ; }
Display faq .
15,669
public function edit ( FaqRequest $ request , Faq $ faq ) { return $ this -> response -> title ( trans ( 'app.edit' ) . ' ' . trans ( 'faq::faq.name' ) ) -> view ( 'faq::faq.edit' , true ) -> data ( compact ( 'faq' ) ) -> output ( ) ; }
Show faq for editing .
15,670
public function update ( FaqRequest $ request , Faq $ faq ) { try { $ attributes = $ request -> all ( ) ; $ faq -> update ( $ attributes ) ; return $ this -> response -> message ( trans ( 'messages.success.updated' , [ 'Module' => trans ( 'faq::faq.name' ) ] ) ) -> code ( 204 ) -> status ( 'success' ) -> url ( guard_ur...
Update the faq .
15,671
public function destroy ( FaqRequest $ request , Faq $ faq ) { try { $ faq -> delete ( ) ; return $ this -> response -> message ( trans ( 'messages.success.deleted' , [ 'Module' => trans ( 'faq::faq.name' ) ] ) ) -> code ( 202 ) -> status ( 'success' ) -> url ( guard_url ( 'faq/faq/0' ) ) -> redirect ( ) ; } catch ( Ex...
Remove the faq .
15,672
public function view ( UserPolicy $ user , Faq $ faq ) { if ( $ user -> canDo ( 'faq.faq.view' ) && $ user -> isAdmin ( ) ) { return true ; } return $ faq -> user_id == user_id ( ) && $ faq -> user_type == user_type ( ) ; }
Determine if the given user can view the faq .
15,673
public function destroy ( UserPolicy $ user , Faq $ faq ) { return $ faq -> user_id == user_id ( ) && $ faq -> user_type == user_type ( ) ; }
Determine if the given user can delete the given faq .
15,674
public function create ( CategoryRequest $ request ) { $ category = $ this -> repository -> newInstance ( [ ] ) ; return $ this -> response -> title ( trans ( 'app.new' ) . ' ' . trans ( 'faq::category.name' ) ) -> view ( 'faq::category.create' , true ) -> data ( compact ( 'category' ) ) -> output ( ) ; }
Show the form for creating a new category .
15,675
public function store ( CategoryRequest $ request ) { try { $ attributes = $ request -> all ( ) ; $ attributes [ 'user_id' ] = user_id ( ) ; $ attributes [ 'user_type' ] = user_type ( ) ; $ category = $ this -> repository -> create ( $ attributes ) ; return $ this -> response -> message ( trans ( 'messages.success.crea...
Create new category .
15,676
public function edit ( CategoryRequest $ request , Category $ category ) { return $ this -> response -> title ( trans ( 'app.edit' ) . ' ' . trans ( 'faq::category.name' ) ) -> view ( 'faq::category.edit' , true ) -> data ( compact ( 'category' ) ) -> output ( ) ; }
Show category for editing .
15,677
public function update ( CategoryRequest $ request , Category $ category ) { try { $ attributes = $ request -> all ( ) ; $ category -> update ( $ attributes ) ; return $ this -> response -> message ( trans ( 'messages.success.updated' , [ 'Module' => trans ( 'faq::category.name' ) ] ) ) -> code ( 204 ) -> status ( 'suc...
Update the category .
15,678
public function destroy ( CategoryRequest $ request , Category $ category ) { try { $ category -> delete ( ) ; return $ this -> response -> message ( trans ( 'messages.success.deleted' , [ 'Module' => trans ( 'faq::category.name' ) ] ) ) -> code ( 202 ) -> status ( 'success' ) -> url ( guard_url ( 'faq/category/0' ) ) ...
Remove the category .
15,679
function getEncryption ( ) { if ( isset ( $ this -> xref [ 'trailer' ] [ 1 ] [ '/Encrypt' ] ) ) { $ this -> success = false ; $ this -> errormsg = sprintf ( "File is encrypted!" ) ; return false ; } }
Check Trailer for Encryption
15,680
function pdf_find_xref ( ) { fseek ( $ this -> f , - min ( filesize ( $ this -> filename ) , 1500 ) , SEEK_END ) ; $ data = fread ( $ this -> f , 1500 ) ; $ pos = strlen ( $ data ) - strpos ( strrev ( $ data ) , strrev ( 'startxref' ) ) ; $ data = substr ( $ data , $ pos ) ; if ( ! preg_match ( '/\s*(\d+).*$/s' , $ dat...
Find the xref - Table
15,681
function pdf_resolve_object ( & $ c , $ obj_spec , $ encapsulate = true ) { if ( ! is_array ( $ obj_spec ) ) { return false ; } if ( $ obj_spec [ 0 ] == PDF_TYPE_OBJREF ) { if ( isset ( $ this -> xref [ 'xref' ] [ $ obj_spec [ 1 ] ] [ $ obj_spec [ 2 ] ] ) ) { $ old_pos = ftell ( $ c -> file ) ; $ c -> reset ( $ this ->...
Resolve an object
15,682
function pdf_read_token ( & $ c ) { if ( count ( $ c -> stack ) ) { return array_pop ( $ c -> stack ) ; } do { if ( ! $ c -> ensure_content ( ) ) { return false ; } $ c -> offset += _strspn ( $ c -> buffer , " \n\r\t" , $ c -> offset ) ; } while ( $ c -> offset >= $ c -> length - 1 ) ; $ char = $ c -> buffer [ $ c -> o...
Reads a token from the file
15,683
public static function in_range ( $ u , $ lo , $ hi ) { if ( ( ( $ lo ^ $ hi ) & $ lo ) == 0 && ( ( $ lo ^ $ hi ) & $ hi ) == ( $ lo ^ $ hi ) && ( ( $ lo ^ $ hi ) & ( ( $ lo ^ $ hi ) + 1 ) ) == 0 ) return ( $ u & ~ ( $ lo ^ $ hi ) ) == $ lo ; else return $ lo <= $ u && $ u <= $ hi ; }
From hb - private . hh
15,684
function reset ( $ pos = null , $ l = 100 ) { if ( ! is_null ( $ pos ) ) { fseek ( $ this -> file , $ pos ) ; } $ this -> buffer = $ l > 0 ? fread ( $ this -> file , $ l ) : '' ; $ this -> offset = 0 ; $ this -> length = strlen ( $ this -> buffer ) ; $ this -> stack = array ( ) ; }
and reset the buffered data
15,685
public static function create ( RequestInterface $ request ) : Response { $ negotiator = new Negotiator ( ) ; $ acceptHeader = $ request -> getHeaderLine ( "accept" ) ? : self :: DEFAULT_ACCEPT ; $ priorities = [ "text/html; charset=UTF-8" , "application/json" , "application/xml;q=0.5" , ] ; static :: $ mediaType = $ n...
A Response object is a PSR - 7 compatible object that is created here from the current Request . The type of Response that is returned is determined by the type of request .
15,686
public static function registerResponseClass ( string $ responseClassName , string ... $ accept ) : void { if ( empty ( $ accept ) ) { $ accept = [ self :: DEFAULT_ACCEPT ] ; } foreach ( $ accept as $ a ) { static :: $ responseClassLookup [ $ a ] = $ responseClassName ; } }
In order for this factory to create the correct type of Response class names need to be registered to match the request s accept header . This allows the web client to request a web page in HTML format over a web API in JSON format for example .
15,687
public function getHttpHeadersArray ( ) : array { $ headers = [ ] ; foreach ( $ this -> server as $ key => $ value ) { if ( strpos ( $ key , "HTTP_" ) !== 0 ) { continue ; } $ headerName = substr ( $ key , strlen ( "HTTP_" ) ) ; $ headerName = strtoupper ( $ headerName ) ; $ headers [ $ headerName ] = $ value ; } retur...
HTTP headers are case - insensitive so headers are transformed to uppercase .
15,688
public static function composeFromComponents ( string $ scheme = null , string $ authority = null , string $ path = null , string $ query = null , string $ fragment = null ) : Uri { $ uri = "" ; if ( ! is_null ( $ scheme ) && strlen ( $ scheme ) > 0 ) { $ uri .= $ scheme . ":" ; } if ( ( ! is_null ( $ authority ) && st...
Composes a URI reference string from its various components .
15,689
protected function registerPlugin ( ) { $ id = $ this -> options [ 'id' ] ; $ view = $ this -> getView ( ) ; $ assets = CoreAsset :: register ( $ view ) ; if ( $ this -> theme == true ) { ThemeAsset :: register ( $ view ) ; } if ( array_key_exists ( 'defaultView' , $ this -> clientOptions ) && ( $ this -> clientOptions...
Registers the FullCalendar javascript assets and builds the requiered js for the widget and the related events
15,690
public function getCredentials ( ) { $ rc_file = $ this -> parse ( ) ; if ( array_key_exists ( 'username' , $ rc_file ) && array_key_exists ( 'username' , $ rc_file ) ) { return [ $ rc_file [ 'username' ] , $ rc_file [ 'token' ] ] ; } }
Get credentials from config file .
15,691
protected function serve ( InputInterface $ input , OutputInterface $ output ) { $ port = $ this -> port ( $ input ) ; $ continue = true ; do { if ( $ this -> check_port ( $ port ) ) { $ this -> output -> writeln ( '<info>Running php artisan serve --port=' . $ port . '</info>' ) ; exec ( 'php artisan serve --port=' . $...
Serve command .
15,692
protected function check_port ( $ port = 8000 , $ host = '127.0.0.1' , $ timeout = 3 ) { $ fp = @ fsockopen ( $ host , $ port , $ errno , $ errstr , $ timeout ) ; if ( ! $ fp ) { return true ; } else { fclose ( $ fp ) ; return false ; } }
Check if port is in use .
15,693
protected function port ( InputInterface $ input ) { $ name = $ input -> getArgument ( 'port' ) ; return isset ( $ name ) ? ( int ) $ name : 8080 ; }
Obtain port .
15,694
public function githubCreateRepo ( InputInterface $ input , OutputInterface $ output ) { $ this -> api -> setCredentials ( $ this -> getCredentials ( $ output ) ) ; $ name = $ this -> repoName ( $ input ) ; try { $ this -> api -> createRepo ( $ name , $ this -> repoDescription ( $ input ) ) ; } catch ( ServerException ...
Github create repo command .
15,695
protected function showError ( ClientException $ ce , OutputInterface $ output ) { if ( $ ce -> getResponse ( ) -> getStatusCode ( ) == 422 ) { $ output -> writeln ( '<error>Repository already exists</error>' ) ; die ( ) ; } $ output -> writeln ( '<error>Client Request exception thrown</error>' ) ; die ( ) ; }
Show error .
15,696
public function getCredentials ( OutputInterface $ output ) { $ credentials = $ this -> parser -> getCredentials ( ) ; if ( is_null ( $ credentials ) ) { $ this -> showErrorRunLlumInitFirst ( $ output , "Credentials" ) ; } ; return $ credentials ; }
Get credentials .
15,697
protected function repoName ( InputInterface $ input ) { $ name = $ input -> getArgument ( 'name' ) ; return isset ( $ name ) ? $ name : basename ( getcwd ( ) ) ; }
Obtain repo name .
15,698
protected function packageList ( ) { $ packages = $ this -> config -> all ( ) ; foreach ( $ packages as $ name => $ package ) { $ this -> output -> writeln ( '<info>' . $ name . '</info> | ' . $ this -> parsePackageInfo ( $ package ) ) ; } }
Shows list of supported packages .
15,699
protected function sqliteEnv ( ) { passthru ( 'sed -i \'s/^DB_/#DB_/g\' .env ' , $ error ) ; if ( $ error !== 0 ) { $ this -> output -> writeln ( '<error>Error commenting DB_ entries in .env file </error>' ) ; } passthru ( 'sed -i \'s/.*DB_HOST.*/DB_CONNECTION=sqlite\n&/\' .env' , $ error ) ; if ( $ error !== 0 ) { $ t...
Config . env file .