idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
15,300
public function getComments ( $ postId = false ) { $ cArgs = [ 'author__in' => $ this -> ID , 'orderby' => 'comment_date_gmt' ] ; if ( $ postId ) { $ cArgs [ 'post_id' ] = $ postId ; } $ comments = [ ] ; foreach ( get_comments ( $ cArgs ) as $ c ) { $ comments [ ] = Comment :: find ( $ c -> comment_ID ) ; } return $ co...
Return all comment
15,301
public function getPosts ( $ limit = false , $ offset = false ) { if ( ! $ limit ) { $ limit = Option :: get ( 'posts_per_page' ) ; } return Post :: getByAuthor ( $ this -> ID , $ limit , $ offset ) ; }
Get all posts
15,302
public function getFullName ( ) { $ fullName = $ this -> getFirstName ( ) . ' ' . $ this -> getLastName ( ) ; if ( strlen ( trim ( $ fullName ) ) ) { return $ fullName ; } return $ this -> getDisplayName ( ) ; }
Return the name and surname from the User .
15,303
public function setFacebook ( $ value ) { $ nickname = $ url = '' ; if ( strlen ( $ value ) ) { if ( strpos ( $ value , 'http' ) !== false ) { $ url = $ value ; $ nickname = substr ( $ value , strrpos ( $ value , '/' ) + 1 ) ; } else { $ nickname = $ value ; $ url = 'https://facebook.com/' . $ value ; } } update_user_m...
Set new Facebook
15,304
public function setRol ( $ rol ) { if ( in_array ( $ rol , self :: getAllowedRoles ( ) ) ) { $ u = new \ WP_User ( $ this -> ID ) ; $ u -> set_role ( $ rol ) ; return true ; } return false ; }
Set a rol to User
15,305
public function getTotalPosts ( ) { global $ wpdb ; return $ wpdb -> get_var ( $ wpdb -> prepare ( 'SELECT COUNT(*) FROM ' . $ wpdb -> prefix . 'posts WHERE post_author = %d AND post_type = %s AND post_status = %s' , $ this -> ID , Post :: TYPE_POST , Post :: STATUS_PUBLISH ) ) ; }
Return the total of publish posts
15,306
public function set ( $ type , $ value , $ useProperty = false ) { $ value = preg_replace ( '/\s\s+/' , ' ' , $ this -> trans ( $ value ) ) ; $ keys = array ( ) ; $ keysProp = array ( ) ; switch ( $ type ) { case 'title' : $ keysProp [ ] = 'og:title' ; $ keys [ ] = 'title' ; $ keys [ ] = 'twitter:title' ; break ; case ...
Set a share meta value .
15,307
public function get ( $ type ) { $ ret = null ; if ( 'image' == $ type ) { if ( isset ( $ this -> metasProp [ 'og:image' ] ) ) { $ ret = $ this -> metasProp [ 'og:image' ] ; } elseif ( $ this -> getParameter ( 'nyroDev_utility.share.image' ) ) { $ ret = $ this -> getParameter ( 'nyroDev_utility.share.image' ) ; } } els...
Get a share meta value .
15,308
public function setAll ( $ title , $ description , $ image = null ) { $ this -> setTitle ( $ title ) ; $ this -> setDescription ( $ description ) ; if ( ! is_null ( $ image ) ) { $ this -> setImage ( $ image ) ; } }
Set all default values at once .
15,309
public function setImage ( $ image , $ getAndSetDimensions = true ) { $ this -> set ( 'image' , $ image ) ; if ( $ getAndSetDimensions ) { $ imageSize = $ this -> container -> get ( ImageService :: class ) -> getImageSize ( $ image ) ; if ( is_array ( $ imageSize ) && count ( $ imageSize ) ) { $ this -> set ( 'og:image...
Set the share absolute image URL .
15,310
public function getMetas ( ) { $ ret = array ( ) ; if ( ! isset ( $ this -> metas [ 'title' ] ) && $ this -> getParameter ( 'nyroDev_utility.share.title' ) ) { $ this -> setTitle ( $ this -> getParameter ( 'nyroDev_utility.share.title' ) ) ; } if ( ! isset ( $ this -> metas [ 'description' ] ) && $ this -> getParameter...
Get all metas set to be shown in html header .
15,311
public function insert ( $ value , $ priority ) { if ( is_int ( $ priority ) ) { $ priority = [ $ priority , $ this -> counter -- ] ; } parent :: insert ( $ value , $ priority ) ; }
Insert a value into the queue
15,312
public function get_error_message ( ) { if ( $ this -> is_valid ( ) ) { return null ; } static $ errors = [ UPLOAD_ERR_INI_SIZE => 'The file "%s" exceeds the maximum upload size (limit is %s).' , UPLOAD_ERR_FORM_SIZE => 'The file "%s" exceeds the upload limit defined in your form.' , UPLOAD_ERR_PARTIAL => 'The file "%s...
Returns a human readable error string for the file .
15,313
public function upload ( $ target = null , $ append_sub_dirs = false ) { if ( ! \ function_exists ( 'wp_handle_upload' ) ) { require_once ( ABSPATH . 'wp-admin/includes/file.php' ) ; } if ( $ target !== null ) { $ closure = function ( $ upload_dir ) use ( $ target , $ append_sub_dirs ) { $ upload_dir [ 'subdir' ] = '/'...
Move the file to the uploads folder .
15,314
public function add_to_media_library ( ) { if ( $ this -> upload_path === false ) { return false ; } $ attachment = [ 'guid' => $ this -> upload_url , 'post_mime_type' => $ this -> upload_type , 'post_title' => \ pathinfo ( $ this -> upload_path , PATHINFO_FILENAME ) , 'post_content' => '' , 'post_status' => 'inherit' ...
Add an uploaded file into the media library so it is usable in the WordPress admin .
15,315
public function delete_upload ( $ force = true ) { if ( $ this -> get_upload_path ( ) === null ) { return false ; } if ( $ this -> get_id ( ) !== null ) { $ result = ! \ wp_delete_attachment ( $ this -> get_id ( ) , $ force ) === false ; } else { \ wp_delete_file ( $ this -> get_upload_path ( ) ) ; $ result = ! \ file_...
Remove the uploaded version of the file and delete from the media library if added .
15,316
public function to_base64 ( ) { if ( ! empty ( $ this -> get_upload_path ( ) ) ) { return \ base64_encode ( \ file_get_contents ( $ this -> get_upload_path ( ) ) ) ; } return \ base64_encode ( \ file_get_contents ( $ this -> get_tmp_path ( ) ) ) ; }
Return a base64 encoded representation of the upload .
15,317
private function set_client_extension ( ) { $ ext = \ pathinfo ( $ this -> client_name , PATHINFO_EXTENSION ) ; if ( ! empty ( $ ext ) ) { return $ ext ; } return null ; }
Get the client ext of the uploaded file .
15,318
private function check_if_allowed ( ) { $ check = \ wp_check_filetype_and_ext ( $ this -> data [ 'tmp_name' ] , $ this -> client_name ) ; if ( $ check [ 'type' ] !== false ) { $ this -> guessed_type = $ check [ 'type' ] ; $ this -> guessed_extension = $ check [ 'ext' ] ; } if ( ( $ check [ 'type' ] === false || $ check...
Checks if the file passes WordPress upload checks .
15,319
protected function setupSections ( ) { if ( version_compare ( VERSION , '3.3' , '<' ) ) { if ( ! isset ( $ GLOBALS [ 'TL_CONFIG' ] [ 'customSections' ] ) || $ GLOBALS [ 'TL_CONFIG' ] [ 'customSections' ] == '' ) { $ GLOBALS [ 'TL_CONFIG' ] [ 'customSections' ] = 'bootstrap' ; } elseif ( strpos ( $ GLOBALS [ 'TL_CONFIG'...
setup required sections
15,320
public function url ( $ url ) { if ( filter_var ( $ url , FILTER_VALIDATE_URL ) !== false ) { return $ url ; } if ( is_string ( $ url ) ) { return $ this -> parseStringUrl ( $ url ) ; } if ( is_array ( $ url ) ) { return $ this -> make ( new UrlSettings ( $ url ) ) ; } if ( $ url instanceof UrlSettings ) { return $ thi...
Create a url from variable type
15,321
public function create ( ? string $ scheme = null , ? string $ domain = null , $ path = null , ? array $ query = [ ] , ? string $ fragment = null , bool $ trailingSlash = false ) : string { return $ this -> make ( new UrlSettings ( [ 'scheme' => $ scheme , 'domain' => $ domain , 'path' => $ path , 'query' => $ query , ...
Create a url
15,322
public function to ( $ path = null , ? array $ query = [ ] , ? string $ fragment = null , bool $ trailingSlash = false ) : string { return $ this -> create ( null , $ this -> appUrl , $ path , $ query , $ fragment , $ trailingSlash ) ; }
Create a local url appended to the app url .
15,323
protected function parseStringUrl ( ? string $ url ) : string { $ parts = parse_url ( $ url ) ; if ( isset ( $ parts [ 'query' ] ) ) { parse_str ( $ parts [ 'query' ] , $ query ) ; } return $ this -> create ( $ parts [ 'scheme' ] ?? null , $ parts [ 'host' ] ?? null , $ parts [ 'path' ] ?? null , $ query ?? null , $ pa...
Parse url when given as string
15,324
protected function createOutput ( Settings $ settings ) : string { return StrFormat :: format ( '{{scheme}}{{domain}}{{path}}{{query}}{{fragment}}' , $ this -> parseUrlComponents ( $ settings ) , new StrSettings ( [ 'removeUnparsed' => true ] ) ) ; }
Create the URL string
15,325
protected function parseUrlComponents ( UrlSettings $ settings ) : array { return [ 'scheme' => $ this -> getScheme ( $ settings -> scheme , $ settings -> domain ) , 'domain' => $ this -> getDomain ( $ settings -> domain ) , 'path' => $ this -> getPath ( $ settings -> path , $ settings -> trailingSlash ) , 'query' => $...
Parse the parts of the Url
15,326
protected function getScheme ( ? string $ scheme , ? string $ domain = null ) : string { if ( $ scheme === null || $ scheme === '//' ) { return $ this -> tryGuessScheme ( $ domain ) ; } return $ this -> trim ( $ scheme , ':/' ) . '://' ; }
Get url scheme
15,327
protected function tryGuessScheme ( ? string $ domain ) : ? string { if ( $ domain !== null ) { if ( Str :: startsWith ( $ domain , 'https' ) ) { return 'https://' ; } if ( Str :: startsWith ( $ domain , 'http' ) ) { return 'http://' ; } } return ( isset ( $ _SERVER [ 'HTTPS' ] ) && ! empty ( $ _SERVER [ 'HTTPS' ] ) &&...
Get the scheme from the domain
15,328
protected function getQueryString ( ? array $ query ) : ? string { if ( empty ( $ query ) ) { return null ; } return '?' . http_build_query ( $ query , null , '&' , PHP_QUERY_RFC3986 ) ; }
Build query string
15,329
protected function getFragment ( ? string $ fragment ) : ? string { if ( $ fragment === null ) { return null ; } return '#' . $ this -> trim ( $ fragment , '#' ) ; }
Get url fragment
15,330
protected function getTrailingSlash ( string $ item , bool $ trailing ) : string { if ( Str :: contains ( $ item , '.' ) || ! $ trailing ) { return '' ; } return '/' ; }
Check if we should include a trailing slash
15,331
public function get ( $ key , $ default = null ) { return isset ( $ this -> options [ $ key ] ) ? $ this -> options [ $ key ] : $ default ; }
Retrieve one option by key returning a default value if not set
15,332
public function getTypeName ( $ type = null ) { $ group = $ this -> getGroup ( ) ; $ type = $ type === null ? $ this -> getType ( ) : $ type ; return $ GLOBALS [ 'BOOTSTRAP' ] [ 'wrappers' ] [ $ group ] [ $ type ] [ 'name' ] ; }
get type name
15,333
function register ( $ engine , $ extension ) { if ( ! class_exists ( $ engine ) ) { throw new \ InvalidArgumentException ( "Class $engine is not defined" ) ; } if ( ! class_implements ( $ engine , "\\MetaTemplate\\Template\\TemplateInterface" ) ) { throw new \ InvalidArgumentException ( "An engine must implement \\Meta...
Registers an engine with one or more extensions
15,334
private function readTemplateContent ( ) { if ( $ this -> router_instance -> getPageData ( ) [ 'html_file' ] && file_exists ( DIR_BASE . $ this -> router_instance -> getPageData ( ) [ 'html_file' ] ) ) { if ( Settings :: isFrontendLogEnabled ( ) ) { FrontendLogger :: getInstance ( ) -> log ( 'Rendering simple HTML file...
Read template content - file that is set for current requested page
15,335
private function replaceElements ( $ elements , $ res ) { $ replaces = [ ] ; $ disabled_components = Structure :: getDisabledComponents ( ) ; $ cached_components = Structure :: getCachedComponents ( ) ; $ cacher = Cacher :: getInstance ( ) -> getDefaultCacher ( ) ; $ this -> mvc_instance = new MVC ( ) ; foreach ( $ ele...
Replaces component parts with it s real data set in admin panel
15,336
private function callReplace ( $ component ) { ob_start ( ) ; if ( $ component [ 'file' ] == 'plugin' ) { $ selected_plugin_file = Plugin :: getSelectedPluginValue ( $ component [ 'class' ] ) ; if ( $ selected_plugin_file ) { $ file_with_plugin = Finder :: getInstance ( ) -> searchForRealPath ( $ selected_plugin_file ,...
Replace one component value with real data set in admin panel for requested page No check for file existance in it method - for speeding up processing . Anyway you will receive standard php error if requested file is not found .
15,337
public static function format ( string $ string , array $ values , $ options = null ) : string { if ( $ options instanceof Settings ) { $ settings = $ options ; } elseif ( is_array ( $ options ) ) { $ settings = new Settings ( $ options ) ; } else { $ settings = new Settings ( ) ; } $ settings -> hasRequiredSettings ( ...
Parse string to formatted output .
15,338
protected static function parseString ( string $ string , array $ values , Settings $ options ) : string { $ output = str_replace ( array_map ( function ( $ value ) use ( $ options ) { return $ options -> leftSeparator . $ value . $ options -> rightSeparator ; } , array_keys ( $ values ) ) , array_values ( $ values ) ,...
Format the string .
15,339
protected function setUp ( ) { $ this -> services [ 'service' ] -> register ( array ( 'config' => Config :: class , 'routingFactory' => function ( ) { return new Factory ( ) ; } , 'map' => function ( ) { return $ this [ 'routingFactory' ] -> createGroup ( ) ; } , 'request' => function ( ) { return isset ( $ _SERVER [ '...
Setup dependency registry .
15,340
public function request ( ServerRequest $ request = null ) { $ finding = $ this -> map -> findByRequest ( $ request = ( $ request ? : $ this -> request ) ) ; return $ this -> run ( $ finding ) ; }
Execute the http request And return the context
15,341
public function run ( Finding $ finding ) { $ context = $ this -> create ( 'runtime.context' , array ( $ this , $ finding , $ this -> create ( 'runtime.response' ) ) ) ; $ response = $ context -> next ( $ context ) ; if ( $ response instanceof \ Exedra \ Http \ Response ) $ context -> services [ 'response' ] = $ respon...
Execute the call stack
15,342
public function respond ( ServerRequest $ request ) { try { $ response = $ this -> request ( $ request ) -> finalize ( ) -> getResponse ( ) ; } catch ( \ Exception $ e ) { if ( $ failRoute = $ this -> failRoute ) { $ response = $ this -> execute ( $ failRoute , array ( 'exception' => $ e , 'request' => $ request ) , $ ...
Dispatch and return the response Handle uncaught \ Exedra \ Exception \ Exception
15,343
public function dispatch ( ServerRequest $ request = null ) { $ response = $ this -> respond ( $ request ? : $ this -> request ) ; $ response -> send ( ) ; }
Dispatch and send header And print the response
15,344
public function run ( ) : string { if ( null === $ this -> language ) { throw new InvalidConfigException ( 'Language model is not defined.' ) ; } if ( strpos ( $ this -> name , '.' ) !== false ) { $ out = $ this -> getDataByPath ( $ this -> name ) ; } else { $ out = $ this -> model -> { $ this -> name . '_' . $ this ->...
Returns the translation of the field .
15,345
private function getDataByPath ( $ name ) : string { $ namePath = explode ( '.' , $ name ) ; $ out = $ this -> model ; for ( $ i = 0 ; $ i < count ( $ namePath ) ; $ i ++ ) { $ out = $ i + 1 < count ( $ namePath ) ? $ out -> { $ namePath [ $ i ] } : $ out -> { $ namePath [ $ i ] . '_' . $ this -> language -> getShortNa...
Obtaining a field translation of another model along a given path through a series of entities separated by a point .
15,346
function addFile ( $ data , $ name , $ time = 0 ) { $ name = str_replace ( '\\' , '/' , $ name ) ; $ dtime = dechex ( $ this -> unix2DosTime ( $ time ) ) ; $ hexdtime = '\x' . $ dtime [ 6 ] . $ dtime [ 7 ] . '\x' . $ dtime [ 4 ] . $ dtime [ 5 ] . '\x' . $ dtime [ 2 ] . $ dtime [ 3 ] . '\x' . $ dtime [ 0 ] . $ dtime [ 1...
Adds file to archive
15,347
function file ( ) { $ data = implode ( '' , $ this -> datasec ) ; $ ctrldir = implode ( '' , $ this -> ctrl_dir ) ; return $ data . $ ctrldir . $ this -> eof_ctrl_dir . pack ( 'v' , sizeof ( $ this -> ctrl_dir ) ) . pack ( 'v' , sizeof ( $ this -> ctrl_dir ) ) . pack ( 'V' , strlen ( $ ctrldir ) ) . pack ( 'V' , strlen...
Dumps out file
15,348
public static function fromDirectory ( string $ directory ) : self { $ exception = new self ( \ sprintf ( 'Directory "%s" does not exist.' , $ directory ) ) ; $ exception -> directory = $ directory ; return $ exception ; }
Returns a new exception from a directory .
15,349
public function aroundAddAttributeToSelect ( \ Magento \ Catalog \ Model \ ResourceModel \ Product \ Collection $ subject , \ Closure $ proceed , $ attribute , $ joinType = false ) { $ result = $ proceed ( $ attribute , $ joinType ) ; if ( $ attribute == AProdAttr :: CODE_PRICE ) { $ query = $ result -> getSelect ( ) ;...
Add warehouse price to product collection if price attribute is added to select . Add warehouse group price to product collection if special_price attribute is added to select .
15,350
public function aroundGetSelectCountSql ( \ Magento \ Catalog \ Model \ ResourceModel \ Product \ Collection $ subject , \ Closure $ proceed ) { $ result = $ proceed ( ) ; $ result -> reset ( \ Zend_Db_Select :: GROUP ) ; return $ result ; }
Remove group clause to get total count in adminhtml grid .
15,351
private function queryAddWrhsGroupPrice ( $ query ) { $ asCatInv = $ this -> getAliasForCataloginventoryTbl ( $ query ) ; if ( $ asCatInv ) { $ scope = $ this -> scope -> getCurrentScope ( ) ; if ( $ scope == \ Magento \ Framework \ App \ Area :: AREA_FRONTEND ) { $ tbl = $ this -> resource -> getTableName ( EGroupPric...
Add warehouse group price to query if original query contains attribute special_price .
15,352
private function queryAddWrhsPrice ( $ query ) { $ asCatInv = $ this -> getAliasForCataloginventoryTbl ( $ query ) ; if ( $ asCatInv ) { $ tbl = $ this -> resource -> getTableName ( EStockItem :: ENTITY_NAME ) ; $ as = self :: AS_WRHS_STOCK_ITEM ; $ cols = [ AWrhsProd :: A_PRICE_WRHS => EStockItem :: A_PRICE ] ; $ cond...
Add warehouse price to query if original query contains attribute price .
15,353
public function ComplexTypeArrayDemo ( $ arr ) { $ res = Array ( ) ; $ i = - 1 ; $ len = sizeof ( $ arr ) ; while ( ++ $ i < $ len ) $ res [ ] = $ this -> PrintVariable ( $ arr [ $ i ] ) ; return $ res ; }
Print an array of objects
15,354
public function SayHello ( $ name = null ) { $ name = utf8_decode ( $ name ) ; if ( $ name == '' ) $ name = 'unknown' ; return utf8_encode ( 'Hello ' . $ name . '!' ) ; }
Say hello demo
15,355
public function contentReplaceTags ( array $ arrSearchAndReplace ) { foreach ( $ arrSearchAndReplace as $ key => $ value ) { $ arrSearchAndReplace [ '{{' . $ key . '}}' ] = $ value ; unset ( $ arrSearchAndReplace [ $ key ] ) ; } $ this -> contentReplace ( $ arrSearchAndReplace ) ; }
replace the named - tags of
15,356
public function formatOutput ( Route $ route , Output $ output , $ type = self :: STYLE_DETAIL ) { switch ( $ type ) { case self :: STYLE_DETAIL : $ output -> write ( 'Route [' ) ; $ output -> write ( '<success>"' . $ route -> getName ( ) . '"</success>' ) ; $ output -> writeln ( ']' ) ; $ output -> writeln ( "Path:\t\...
Format route output to command line .
15,357
public function parseForEnterpriseAPI ( ResourceModel $ resource ) { $ this -> initDefaultParams ( $ resource ) ; $ this -> parseRedirectUrls ( $ resource ) ; $ this -> parseCustomerInformation ( $ resource ) ; $ this -> parseCreditCardInformation ( $ resource ) ; $ this -> parseRealTimeRecurringEnterprise ( $ resource...
Parse a Payment resource into a request payload
15,358
public function parseForRedirectAPI ( ResourceModel $ resource ) { $ this -> initDefaultParams ( $ resource ) ; $ this -> parseRedirectUrls ( $ resource ) ; $ this -> parseCustomerInformation ( $ resource ) ; $ this -> parseFraudManagementParams ( $ resource ) ; $ this -> parseTransactionRecord ( $ resource ) ; $ this ...
Parse a Redirect resource into a request payload
15,359
public function parseReserveResource ( ResourceModel $ resource ) { $ intent = $ resource -> getIntent ( ) ; $ customer = $ resource -> getCustomer ( ) ; $ transaction = $ resource -> getTransaction ( ) ; $ amount = $ transaction -> getAmount ( ) ; $ total = Formatter :: formatToInteger ( $ amount -> getTotal ( ) ) ; $...
Parse a resource for void credit and capture transactions
15,360
public function getRenderedDataAttribute ( ) : ? string { if ( $ this -> renderedData !== null ) { return $ this -> renderedData ; } if ( $ this -> config -> get ( 'tracker.save_rendered' , true ) && ( $ rendered = $ this -> getAttributeFromArray ( 'data_rendered' ) ) !== null ) { return $ this -> renderedData = $ rend...
Get rendered data
15,361
public static function assets ( $ currentPage , $ fields ) { global $ pagenow ; if ( empty ( $ fields ) || ! in_array ( $ pagenow , $ currentPage ) ) { return ; } $ assets = [ 'scripts' => [ ] , 'styles' => [ ] , ] ; $ paths = apply_filters ( 'ol_zeus_render_assets' , [ ] ) ; if ( ! empty ( $ fields ) ) { foreach ( $ f...
Render assets on asked page .
15,362
public static function assetsInCache ( $ source , $ filename ) { $ dest = OL_ZEUS_DISTPATH . $ filename ; if ( ! file_exists ( $ dest ) ) { $ ctns = file_exists ( $ source ) ? file_get_contents ( $ source ) : '' ; Helpers :: filePutContents ( $ dest , $ ctns , 'This file has been auto-generated' ) ; } }
Create temporary asset accessible file .
15,363
public static function view ( $ template , $ vars , $ context = 'core' ) { echo self :: getInstance ( ) -> twig -> render ( '@' . $ context . '/' . $ template , $ vars ) ; }
Render TWIG component .
15,364
public function onRequestCreate ( Event $ event ) { $ client = $ event [ 'client' ] ; $ token = $ client -> getToken ( ) ; $ event [ 'request' ] -> setHeader ( 'X-Auth-Token' , $ token ) ; }
Add authentication token as a header for requests
15,365
public function onClientCommandCreate ( \ Guzzle \ Common \ Event $ event ) { $ command = $ event [ 'command' ] ; if ( get_class ( $ command ) != 'Guzzle\Openstack\Identity\Command\Authenticate' ) { if ( $ event [ 'client' ] -> getToken ( ) == null ) { throw new OpenstackException ( 'Unauthenticated' ) ; } } }
Check the client authentication token for all commands except authentication
15,366
public function expand ( RamlDoc $ ramlDoc ) { $ ramlDoc -> rawRaml = self :: applyAllToTree ( $ ramlDoc , $ ramlDoc -> rawRaml ) ; return $ this ; }
Applies resource types and traits .
15,367
private static function applyAllToTree ( RamlDoc $ ramlDoc , array & $ item , $ itemKey = NULL ) { if ( RamlDoc :: isValidMethod ( $ itemKey ) && ! empty ( $ item [ RamlSpec :: PROPERTY_APPLY_TRAITS ] ) ) { $ item = self :: applyTraitsToNode ( $ ramlDoc , $ item , $ item [ RamlSpec :: PROPERTY_APPLY_TRAITS ] ) ; } else...
Actually applies resource types and traits .
15,368
public function buildView ( FormView $ view , FormInterface $ form , array $ options ) { $ data = $ form -> getParent ( ) -> getData ( ) ; if ( $ options [ 'currentFile' ] || $ data instanceof AbstractUploadable ) { try { $ currentFile = isset ( $ options [ 'currentFile' ] ) && $ options [ 'currentFile' ] ? $ options [...
Pass the image URL to the view .
15,369
function getTtl ( ) : ? int { if ( is_int ( $ this -> expiration ) ) { return $ this -> expiration ; } if ( $ this -> expiration instanceof \ DateTimeInterface ) { return $ this -> expiration -> getTimestamp ( ) - Clock :: time ( ) ; } if ( $ this -> expiration instanceof \ DateInterval ) { return PsrCacheHelper :: con...
Internal . Do not use .
15,370
public function isEnabled ( float $ percentage , string $ value = "" , string $ salt = "" ) : bool { if ( $ percentage <= 0 ) { return false ; } if ( $ percentage >= 100 ) { return true ; } if ( $ value === "" && $ salt === "" ) { $ max = mt_getrandmax ( ) + 1 ; $ random = mt_rand ( ) / $ max ; return ( $ random < $ pe...
Determine whether something is on for a desired percentage of calls
15,371
public static function run ( App $ app , ? Config $ config = null ) : void { \ ini_set ( 'display_errors' , '0' ) ; \ ini_set ( 'html_errors' , '0' ) ; $ k1 = new static ( $ config ) ; $ k1 -> runApp ( $ app ) ; }
Run K1 eighter serving the given resource or in console mode if launched from command line .
15,372
public function add ( $ prefix , $ dir , $ prepend = false ) { $ prefix = trim ( $ prefix , '\\' ) . '\\' ; $ dir = rtrim ( $ dir , DIRECTORY_SEPARATOR ) . '/' ; if ( isset ( $ this -> prefixes [ $ prefix ] ) === false ) { $ this -> prefixes [ $ prefix ] = [ ] ; } if ( $ prepend ) { array_unshift ( $ this -> prefixes [...
Add a base directory for a given namespace prefix
15,373
public function resolve ( $ class ) { $ result = false ; $ prefix = $ class ; while ( false !== ( $ pos = strrpos ( $ prefix , '\\' ) ) ) { $ prefix = substr ( $ class , 0 , $ pos + 1 ) ; if ( isset ( $ this -> prefixes [ $ prefix ] ) ) { $ result = $ this -> resolveFilename ( $ prefix , str_replace ( '\\' , '/' , subs...
Resolve a class name to path and filename
15,374
protected function load ( $ filename ) { $ success = false ; if ( file_exists ( $ filename ) ) { require $ filename ; $ success = true ; } return $ success ; }
Include class file if given file exists
15,375
public function generate ( $ type , User $ user , $ hours = null ) { $ hours = is_null ( $ hours ) ? 24 : $ hours ; $ user_id = $ user -> id ; $ email = $ user -> getAuthIdentifier ( ) ; $ value = str_shuffle ( sha1 ( $ email . $ type . spl_object_hash ( $ this ) . microtime ( true ) ) ) ; $ token = hash_hmac ( 'sha256...
Generate a new token for the type .
15,376
public function notifyUser ( ) { switch ( $ this -> type ) { case self :: TYPE_PASSWORD_RESET : $ event = new PasswordReset ; break ; case self :: TYPE_ACTIVATION : $ event = new UserActivation ; break ; case self :: TYPE_INVITATION : $ event = new UserInvitation ; break ; } $ this -> user -> notify ( $ event ) ; }
Notify the user of this token .
15,377
public function extend ( $ hours = null ) { $ hours = is_null ( $ hours ) ? 24 : $ hours ; $ this -> update ( [ 'expires_at' => Carbon :: now ( ) -> addHours ( $ hours ) , ] ) ; }
Extend the expiration of the token .
15,378
public function extendByToken ( $ token , $ hours = null ) { $ token = $ this -> findByToken ( $ token ) ; if ( ! is_null ( $ token ) ) { return $ token -> extend ( $ hours ) ; } }
Extend the expiration of a token .
15,379
public function expireByToken ( $ token ) { $ token = $ this -> findByToken ( $ token ) ; if ( ! is_null ( $ token ) ) { return $ token -> expire ( ) ; } }
Find an object by its token and immediately expire it .
15,380
public function set ( string $ name , $ value = null ) : self { $ this -> variables [ $ name ] = $ value ; return $ this ; }
Assign a variable to template
15,381
public function get ( $ variable ) { if ( false === array_key_exists ( $ variable , $ this -> variables ) ) { throw new View \ Exception ( sprintf ( 'Unassigned variable "%s"' , $ variable ) ) ; } return $ this -> variables [ $ variable ] ; }
Get value from template assignments
15,382
public function getAvatars ( array $ accounts ) { $ ids = [ ] ; foreach ( $ accounts as $ account ) { if ( $ account instanceof Account ) { $ ids [ ] = $ account -> getId ( ) ; } else { $ ids [ ] = $ account ; } } $ response = $ this -> client -> sendRequest ( $ this -> getBase ( ) . '/Avatar' , 'POST' , $ ids ) ; if (...
Get avatars .
15,383
public function getAll ( ) { $ response = $ this -> client -> sendRequest ( $ this -> getBase ( ) ) ; try { $ dataSet = new DataSetStruct ( $ response ) ; } catch ( \ InvalidArgumentException $ e ) { throw new UnexpectedValueException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } $ result = [ ] ; $ items = $...
Get all accounts .
15,384
public function get ( $ id ) { $ response = $ this -> client -> sendRequest ( $ this -> getBase ( ) . '/' . $ id ) ; if ( ! is_array ( $ response ) ) { throw new UnexpectedValueException ( 'Array expected, but got ' . gettype ( $ response ) ) ; } try { return new Account ( $ response ) ; } catch ( \ InvalidArgumentExce...
Get account by ID .
15,385
public function convertToJWT ( CryptKey $ privateKey ) { $ tokenBuilder = ( new Builder ( ) ) -> setAudience ( $ this -> getClient ( ) -> getIdentifier ( ) ) -> setId ( $ this -> getIdentifier ( ) , true ) -> setIssuedAt ( time ( ) ) -> setNotBefore ( time ( ) ) -> setExpiration ( $ this -> getExpiryDateTime ( ) -> get...
Generate a JWT from the access token
15,386
public static function rtl ( $ flag = true ) { if ( $ flag ) { return ! empty ( self :: $ options [ 'rtl' ] ) ; } else { return ! empty ( self :: $ options [ 'rtl' ] ) ? ' dir="rtl" ' : ' dir="ltr" ' ; } }
Check if language is RTL or return direction
15,387
public static function translateArray ( array & $ data , bool $ sort = false ) { foreach ( $ data as $ k => $ v ) { $ data [ $ k ] [ 'name' ] = i18n ( null , $ v [ 'name' ] ) ; } if ( $ sort ) { array_key_sort ( $ data , [ 'name' => SORT_ASC ] , [ 'name' => SORT_NATURAL ] ) ; } }
Translate and sort an array
15,388
public function calculateHash ( ) { $ str = $ this -> data [ 'ECM_TRANS_ID' ] . $ this -> data [ 'ECM_TRANS_DATE' ] . $ this -> request -> getPurse ( ) . $ this -> data [ 'ECM_PAYER_ID' ] . $ this -> data [ 'ECM_ITEM_COST' ] . $ this -> data [ 'ECM_QTY' ] . $ this -> request -> getSecret ( ) ; return md5 ( $ str ) ; }
Calculate hash to validate incoming confirmation .
15,389
public static function makeNested ( array $ data ) : array { $ result = [ ] ; foreach ( $ data as $ key => $ value ) { $ keyParts = explode ( ':' , $ key ) ; $ current = & $ result ; foreach ( static :: tail ( $ keyParts ) as $ keyPart ) { if ( ! array_key_exists ( $ keyPart , $ current ) ) { $ current [ $ keyPart ] = ...
Make a flat array nested .
15,390
private static function hasDuplicates ( array $ entityPath ) : bool { $ found = [ ] ; foreach ( $ entityPath as $ field ) { $ key = $ field [ 'field' ] . "\0" . $ field [ 'class' ] ; if ( array_key_exists ( $ key , $ found ) ) { return true ; } $ found [ $ key ] = true ; } return false ; }
Check if any fields appear in an entity path multiple times to avoid weird loops .
15,391
private static function implodeEntityPath ( array $ entityPath ) : string { $ fields = [ ] ; foreach ( $ entityPath as $ item ) { $ fields [ ] = $ item [ 'field' ] ; } return implode ( ':' , $ fields ) ; }
Reduce an entity path to the name that entity gets in the DQL by linking field names with underscores
15,392
private static function findSlug ( array $ classMetadata ) : string { foreach ( $ classMetadata as $ name => $ info ) { if ( $ info [ 'type' ] === 'Slug' ) { return $ name ; } } throw new InvalidFetchFieldsQueryException ( "Class doesn't have a slug field" ) ; }
Find the name of a section s slug field .
15,393
private function getParsedQuantitativeVars ( ) { static $ quantitativeValuesVar = array ( 'numberOfEmployees' => 'schema:numberOfEmployees' , 'annualTurnover' => 'botk:annualTurnover' , 'ebitda' => 'botk:ebitda' , 'netProfit' => 'botk:netProfit' , 'hasTotDevelopers' => 'botk:hasTotDevelopers' , 'itBudget' => 'botk:itBu...
return a structured info to generate rdf code for quantitative values
15,394
public function findModel ( $ id , $ slug = '' ) { if ( $ this -> _model === null ) { if ( ( $ this -> _model = $ id ? Post :: findOne ( $ id ) : Post :: findOne ( [ 'slug' => $ slug ] ) ) !== null ) { return $ this -> _model ; } else { throw new NotFoundHttpException ( Module :: t ( 'core' , 'The requested model does ...
Finds the Post model based on its primary key value . If the model is not found a 404 HTTP exception will be thrown .
15,395
public function set ( $ id , $ definition , $ args = null , $ factory = false ) { if ( isset ( $ this -> _definitions [ $ id ] ) ) { throw new Exceptions \ ServiceOverride ( 'Service "' . $ id . '" already exists' ) ; } $ definition = $ this -> normalizeDefinition ( $ definition ) ; if ( $ args !== null ) { $ args = $ ...
Set service definition
15,396
public function setAlias ( $ existsId , $ newId ) { if ( isset ( $ this -> _definitions [ $ newId ] ) ) { throw new Exceptions \ ServiceOverride ( 'Service "' . $ newId . '" already exists' ) ; } $ this -> _definitions [ $ newId ] = $ this -> getDefinition ( $ existsId ) ; }
Set alias for service
15,397
public function setParemetersConfig ( ConfigInterface $ config , $ lockExchange = true ) { if ( $ this -> _parametersConfigLock ) { throw new Exceptions \ ForbiddenAction ( 'Config is locked and cannot be exchanged' ) ; } $ this -> _parametersConfig = $ config ; $ this -> _parametersConfigLock = $ lockExchange ; return...
Set config with parameters
15,398
public function getParametersConfig ( ) { if ( $ this -> _parametersConfig === null ) { $ this -> _parametersConfig = new Config ( ) ; $ this -> _parametersConfigLock = true ; } return $ this -> _parametersConfig ; }
Get config with parameters
15,399
protected function getLocatorByServiceId ( $ id ) { if ( isset ( $ this -> _locatorsResolved [ $ id ] ) ) { return $ this -> _locatorsResolved [ $ id ] ; } foreach ( $ this -> _locators as $ locator ) { if ( $ locator -> has ( $ id ) ) { $ this -> _locatorsResolved [ $ id ] = $ locator ; return $ locator ; } } }
Get resolve locator by service ID