idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
13,100 | public function getByUser ( int $ id , int $ trackableType = Tracker :: TRACKER_ANY , int $ perPage = 15 ) : LengthAwarePaginator { return $ this -> getModel ( ) -> newQuery ( ) -> where ( 'user_id' , $ id ) -> where ( $ this -> typeClosure ( $ trackableType ) ) -> paginate ( $ perPage ) ; } | Get track by user |
13,101 | public function getByIpv4 ( $ ip , int $ trackableType = Tracker :: TRACKER_ANY , int $ perPage = 15 ) : LengthAwarePaginator { return $ this -> getModel ( ) -> newQuery ( ) -> where ( 'ipv4' , $ this -> getLongIp ( $ ip ) ) -> where ( $ this -> typeClosure ( $ trackableType ) ) -> paginate ( $ perPage ) ; } | Get tracks by IPv4 |
13,102 | public function getByIpv4Range ( $ ipMin , $ ipMax = Settings :: IP_MAX , int $ trackableType = Tracker :: TRACKER_ANY , int $ perPage = 15 ) : LengthAwarePaginator { $ min = $ this -> getLongIp ( $ ipMin ) ; $ max = $ this -> getLongIp ( $ ipMax ) ; return $ this -> getModel ( ) -> newQuery ( ) -> whereBetween ( 'ipv4... | Get tracks by IPv4 range |
13,103 | public function getByFlagLevel ( int $ level , int $ trackableType = Tracker :: TRACKER_ANY , int $ perPage = 15 ) : LengthAwarePaginator { return $ this -> getModel ( ) -> newQuery ( ) -> where ( 'level' , $ level ) -> where ( $ this -> typeClosure ( $ trackableType ) ) -> paginate ( $ perPage ) ; } | Get tracks by flag level |
13,104 | public function getByFlagRange ( int $ min , int $ max = Settings :: FLAG_MAX , int $ trackableType = Tracker :: TRACKER_ANY , int $ perPage = 15 ) : LengthAwarePaginator { $ query = $ this -> getModel ( ) -> newQuery ( ) ; if ( $ max === Settings :: FLAG_MAX ) { $ query -> where ( 'level' , '>=' , $ min ) ; } else { $... | Get tracks by flag range |
13,105 | public function deleteTracks ( string $ typeName , ? int $ typeId = null , ? int $ expiryTime = 0 , int $ trackableType = Tracker :: TRACKER_LIVE ) : int { $ query = $ this -> getModel ( ) -> newQuery ( ) -> where ( 'type' , $ this -> getAlias ( $ typeName ) ) ; if ( $ typeId !== - 1 ) { $ query -> where ( 'type_id' , ... | Delete tracks for given type |
13,106 | public function scopeType ( $ query , int $ type = Tracker :: TRACKER_ANY ) { if ( $ type === Tracker :: TRACKER_ANY ) { return null ; } return $ query -> where ( 'trackable_type' , $ type ) ; } | Get tracker by trackable type |
13,107 | public static function connect ( ) { if ( self :: $ memcached === null ) { $ config = \ Skeleton \ Object \ Config :: $ cache_handler_config ; self :: $ memcached = new \ Memcached ( ) ; self :: $ memcached -> setOption ( \ Memcached :: OPT_SERIALIZER , \ Memcached :: SERIALIZER_IGBINARY ) ; self :: $ memcached -> setO... | Get the current memcached object |
13,108 | protected function overwriteLastValueFromStructure ( array & $ structure , $ value ) { $ pointer = & $ structure ; $ currentKey = key ( $ pointer ) ; $ currentValue = & $ pointer [ $ currentKey ] ; while ( is_array ( $ currentValue ) ) { $ pointer = & $ currentValue ; $ currentKey = key ( $ pointer ) ; $ currentValue =... | Overwrite the last child of a structure for given value . |
13,109 | public function getChildren ( $ parent_id = null ) { $ parent_id = $ parent_id ?? $ this -> id ; $ children = $ this :: find ( ) -> where ( [ 'parent_id' => $ parent_id , 'show' => true ] ) -> orderBy ( [ 'position' => SORT_ASC ] ) -> all ( ) ; return $ children ; } | Gets shown children |
13,110 | public function getAllChildren ( $ parent_id = null ) { $ parent_id = $ parent_id ?? $ this -> id ; $ children = $ this :: find ( ) -> where ( [ 'parent_id' => $ parent_id ] ) -> all ( ) ; return $ children ; } | Gets all children |
13,111 | public static function get ( string $ id , string $ lng = '' ) { if ( ! isset ( self :: $ cached_data [ $ id ] ) ) { $ translation_obj = TranslationRepository :: findOneEntityById ( $ id ) ; if ( $ translation_obj ) { self :: $ cached_data [ $ id ] = $ translation_obj -> getAsArray ( ) ; } } if ( ! $ lng ) { return sel... | Get translation for selected language |
13,112 | public function addButtons ( $ buttons ) { array_push ( $ buttons , '|' ) ; foreach ( $ this -> configs as $ key => $ file ) { if ( empty ( $ file ) && 'media' !== $ key ) { continue ; } array_push ( $ buttons , $ key ) ; } return $ buttons ; } | Add buttons to tinyMCE . |
13,113 | public function addPlugins ( $ plugins ) { foreach ( $ this -> configs as $ key => $ file ) { if ( empty ( $ file ) ) { continue ; } $ plugins [ $ key ] = $ file ; } return $ plugins ; } | Add plugins to tinyMCE . |
13,114 | public function addShortcodesFrontend ( ) { remove_filter ( 'the_content' , 'wpautop' ) ; remove_filter ( 'the_content' , 'wptexturize' ) ; add_filter ( 'the_content' , [ & $ this , 'contentFormatter' ] , 99 ) ; remove_filter ( 'comment_text' , 'wpautop' ) ; remove_filter ( 'comment_text' , 'wptexturize' ) ; add_filter... | Enable shortcodes WP functions . |
13,115 | public function contentFormatter ( $ content ) { $ new_content = '' ; $ pattern_full = '{(\[raw\].*?\[/raw\])}is' ; $ pattern_contents = '{\[raw\](.*?)\[/raw\]}is' ; $ pieces = preg_split ( $ pattern_full , $ content , - 1 , PREG_SPLIT_DELIM_CAPTURE ) ; foreach ( $ pieces as $ piece ) { if ( preg_match ( $ pattern_cont... | Delete Wordpress auto - formatting . |
13,116 | public function serialize ( Job $ job ) { $ attributes = $ job -> getAttributes ( ) ; $ attributes [ 'className' ] = get_class ( $ job ) ; $ attributes [ 'type' ] = $ job -> getType ( ) ; return $ attributes ; } | Convert a job into an array that can be passed on to a backend . |
13,117 | public function deserialize ( $ attributes ) { if ( isset ( $ attributes [ 'className' ] ) ) { $ className = $ attributes [ 'className' ] ; $ job = new $ className ( ) ; unset ( $ attributes [ 'className' ] ) ; $ job -> setType ( $ attributes [ 'type' ] ) ; unset ( $ attributes [ 'type' ] ) ; $ job -> setAttributes ( $... | Convert an array provided by a backend into a Job instance . |
13,118 | public function actionIndex ( ) { $ rates = Currency :: find ( ) -> orderBy ( 'id DESC' ) -> all ( ) ; $ model = new Currency ( ) ; if ( Yii :: $ app -> request -> isPost ) { if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { if ( $ model -> validate ( ) ) { $ model -> save ( ) ; $ this -> trigger ( self ... | Lists all Currency models . |
13,119 | public function actionUpdate ( $ id ) { if ( ! empty ( $ id ) ) { $ model = Currency :: findOne ( $ id ) ; } else { $ model = new Currency ( ) ; } if ( Yii :: $ app -> request -> isPost ) { if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { if ( $ model -> validate ( ) ) { $ model -> save ( ) ; } return $... | Updates an existing Currency model . If update is successful the browser will be redirected to the view page . |
13,120 | private function getUrl ( ) { if ( ! $ this -> markActive ) return '' ; $ mid = \ Yii :: $ app -> controller -> module -> id == \ Yii :: $ app -> id ? '' : \ Yii :: $ app -> controller -> module -> id ; $ cid = \ Yii :: $ app -> controller -> id ; $ aid = \ Yii :: $ app -> controller -> action -> id ; $ id = isset ( $ ... | current choice mark as an active |
13,121 | public function get ( string $ key , $ default = null ) { if ( $ this -> has ( $ key ) ) { if ( $ this -> get_raw ( $ key ) === null ) { return null ; } if ( \ is_array ( $ this -> get_raw ( $ key ) ) ) { return \ array_map ( [ $ this , 'sanitise_array' ] , $ this -> get_raw ( $ key ) ) ; } if ( $ this -> get_raw ( $ k... | Gets a sanitized value from the bag or a supplied default if not present . |
13,122 | public function get_numeric ( string $ key , $ default = null ) { return \ filter_var ( $ this -> get ( $ key , $ default ) , FILTER_SANITIZE_NUMBER_FLOAT , FILTER_FLAG_ALLOW_FRACTION ) ; } | Gets a numeric value from the bag . |
13,123 | public function get_regex ( $ key , $ pattern , $ default = null ) { $ filtered = \ filter_var ( $ this -> get ( $ key ) , FILTER_VALIDATE_REGEXP , [ "options" => [ "regexp" => $ pattern , ] , ] ) ; if ( $ filtered === false ) { return $ default ; } return $ filtered ; } | Only return a value if it matches the supplied regex pattern . |
13,124 | public function sanitise_array ( $ value ) { if ( \ is_array ( $ value ) ) { return $ value ; } else { if ( $ value instanceof File ) { return $ value ; } return \ sanitize_textarea_field ( $ value ) ; } } | Callback for performing recursive sanitization on an array of values . |
13,125 | public function process ( ContainerBuilder $ container ) : void { $ definition = $ container -> getDefinition ( PathAncestorMatcher :: class ) ; $ voters = [ ] ; foreach ( $ container -> findTaggedServiceIds ( 'knp_menu.voter' ) as $ id => $ tags ) { $ tag = $ tags [ 0 ] ; $ priority = isset ( $ tag [ 'priority' ] ) ? ... | Add the menu voters to the path ancestor matcher . |
13,126 | public function generate ( ) { $ output = parent :: generate ( ) ; $ columnSet = \ Netzmacht \ ColumnSet \ ColumnsetModel :: findByPK ( $ this -> columnset_id ) ; if ( TL_MODE == 'BE' ) { $ output = sprintf ( '<h1>%s <small>[%s: %s]</small></h1>%s' , $ this -> headline , $ GLOBALS [ 'TL_LANG' ] [ 'CTE' ] [ 'bootstrap_c... | generate column set |
13,127 | protected function compile ( ) { $ data = deserialize ( $ this -> columnset , true ) ; $ articles = array ( ) ; $ container = \ Netzmacht \ ColumnSet \ ColumnSet :: prepareContainer ( $ this -> columnset_id ) ; $ i = 0 ; foreach ( $ data as $ article ) { $ articles [ ] = array ( 'article' => $ this -> getArticle ( $ ar... | compile column set |
13,128 | public static function beginsWith ( string $ haystack , string $ needle , bool $ caseSensitive = false ) : bool { $ length = strlen ( $ needle ) ; return ( $ caseSensitive === false ) ? strncasecmp ( $ haystack , $ needle , $ length ) === 0 : strncmp ( $ haystack , $ needle , $ length ) === 0 ; } | Determine if a string begins with another |
13,129 | public static function endsWith ( string $ haystack , string $ needle , bool $ caseSensitive = false ) : bool { $ test = substr ( $ haystack , - strlen ( $ needle ) ) ; return ( $ caseSensitive === false ) ? strcasecmp ( $ test , $ needle ) === 0 : strcmp ( $ test , $ needle ) === 0 ; } | Determine if a string ends with another |
13,130 | public static function before ( string $ haystack , string $ needle , bool $ useLastNeedle = false ) : string { $ pos = static :: getNeedlePosition ( $ haystack , $ needle , $ useLastNeedle ) ; if ( $ pos === false ) { return $ haystack ; } return substr ( $ haystack , 0 , $ pos ) ; } | Get the substring that occurs before another |
13,131 | public static function after ( string $ haystack , string $ needle , bool $ useLastNeedle = false ) : string { $ pos = static :: getNeedlePosition ( $ haystack , $ needle , $ useLastNeedle ) ; if ( $ pos === false ) { return $ haystack ; } return substr ( $ haystack , $ pos + strlen ( $ needle ) ) ; } | Get the substring that occurs after another |
13,132 | public static function random ( int $ length ) : string { $ byteLength = ( $ length < 10 ) ? 10 : $ length ; $ chars = base64_encode ( random_bytes ( $ byteLength ) ) ; $ chars = str_replace ( [ "+" , "/" , "=" ] , "" , $ chars ) ; return substr ( $ chars , 0 , $ length ) ; } | Get a random string |
13,133 | public static function toNumber ( $ str ) { if ( is_string ( $ str ) ) { $ str = preg_replace ( "~[^0-9-.]~" , "" , $ str ) ; } return ( strpos ( $ str , "." ) === false ) ? intval ( $ str ) : floatval ( $ str ) ; } | Convert a string to a number |
13,134 | public static function toBoolean ( $ str ) { if ( ! is_string ( $ str ) ) { $ str = strval ( $ str ) ; } $ str = strtolower ( $ str ) ; return self :: STRING_TO_BOOL_MAP [ $ str ] ?? null ; } | Convert boolean strings to real booleans |
13,135 | public static function toSnakeCase ( string $ str , bool $ uppercase = false ) : string { $ str = trim ( $ str ) ; $ str = preg_replace ( "~[^a-z0-9]+~i" , "_" , $ str ) ; $ fn = function ( $ arg ) { $ match = $ arg [ 0 ] ; return $ match [ 0 ] . "_" . $ match [ 1 ] ; } ; $ ret = preg_replace_callback ( "~([a-z])[A-Z]~... | Convert a string to snake_case |
13,136 | public static function stripPostNewlineTabs ( string $ str ) : string { $ regex = "~" . PHP_EOL . "[\t]+~" ; return preg_replace ( $ regex , PHP_EOL , $ str ) ; } | Remove all tabs that occur immediately after a newline |
13,137 | public static function summarize ( string $ str , int $ maxLength , string $ ellipsis = "..." , string $ needle = "" ) : string { $ length = mb_strlen ( $ str ) ; if ( $ length <= $ maxLength ) { return $ str ; } $ endPos = $ maxPos = $ maxLength - mb_strlen ( $ ellipsis ) ; if ( $ needle !== "" ) { $ offset = $ maxPos... | Summarize a string to a given max length |
13,138 | public static function replace ( string $ str , array $ values ) : string { return str_replace ( array_keys ( $ values ) , array_values ( $ values ) , $ str ) ; } | Handle string replacements given an array of find = > replace values |
13,139 | protected function findBundleFiles ( PackageInterface $ package ) { $ installPath = $ this -> composer -> getInstallationManager ( ) -> getInstallPath ( $ package ) ; $ autoload = $ package -> getAutoload ( ) ; if ( isset ( $ autoload [ 'psr-0' ] ) ) { $ installPath .= '/' . current ( $ autoload [ 'psr-0' ] ) ; } if ( ... | This method tries the find the BundleFile in the root of the given package . At this moment we don t support bundles that don t have the Bundle file in the package root . |
13,140 | public function getFQCN ( PackageInterface $ package , $ bundleFileName ) { $ bundleName = substr ( basename ( $ bundleFileName ) , 0 , - 4 ) ; $ autoload = $ package -> getAutoload ( ) ; if ( isset ( $ autoload [ 'psr-0' ] ) ) { $ namespace = key ( $ autoload [ 'psr-0' ] ) ; return rtrim ( $ namespace , '\\' ) . '\\' ... | Try to determine the package name with the filename and the package autoload definition . This won t work 100% f . e . with Bundles that have only have an autoloader prefix instead of the full namespace untill the BundleFile |
13,141 | public function dequeue ( array $ options = array ( ) ) { $ match = false ; foreach ( $ this -> queue as $ idx => $ attributes ) { if ( isset ( $ options [ "exclude" ] ) ) { $ match = ! in_array ( $ attributes [ "type" ] , $ options [ "exclude" ] ) ; } else { if ( isset ( $ options [ "only" ] ) ) { $ match = in_array (... | Get a job from the pipeline and return its attributes . |
13,142 | public function find ( $ id ) { foreach ( $ this -> locked as $ attributes ) { if ( $ attributes [ 'id' ] == $ id ) { return $ attributes ; } } foreach ( $ this -> failed as $ attributes ) { if ( $ attributes [ 'id' ] == $ id ) { return $ attributes ; } } foreach ( $ this -> queue as $ attributes ) { if ( $ attributes ... | Find a specific job in the pipeline using its id and return its attributes . |
13,143 | public function complete ( $ attributes ) { foreach ( $ this -> locked as $ idx => $ job ) { if ( $ job [ 'id' ] == $ attributes [ 'id' ] ) { unset ( $ this -> locked [ $ idx ] ) ; return ; } } } | Mark a job as completed . |
13,144 | public function reset ( $ attributes ) { foreach ( $ this -> failed as $ idx => $ job ) { if ( $ job [ 'id' ] == $ attributes [ 'id' ] ) { unset ( $ this -> failed [ $ idx ] ) ; break ; } } foreach ( $ this -> locked as $ idx => $ job ) { if ( $ job [ 'id' ] == $ attributes [ 'id' ] ) { unset ( $ this -> locked [ $ idx... | Reset a job so it can be picked up again . |
13,145 | public function fail ( $ attributes ) { foreach ( $ this -> locked as $ idx => $ job ) { if ( $ job [ 'id' ] == $ attributes [ 'id' ] ) { unset ( $ this -> locked [ $ idx ] ) ; break ; } } $ attributes [ 'status' ] = 'failed' ; $ this -> failed [ ] = $ attributes ; } | Mark a job as failed . |
13,146 | public function hasGrantType ( $ grantType ) { $ grants = explode ( ',' , $ this -> Grants ) ; return ! empty ( $ grants ) && in_array ( $ grantType , $ grants ) ; } | Checks whether this ClientEntity has the given grant type . |
13,147 | public function onBeforeWrite ( ) { parent :: onBeforeWrite ( ) ; if ( empty ( $ this -> Secret ) ) { $ this -> Secret = $ this -> generateSecret ( ) ; } if ( empty ( $ this -> Identifier ) ) { $ this -> Identifier = $ this -> generateSecret ( ) ; } } | On before write . Generate a secret if we don t have one . |
13,148 | protected function compile ( ) { if ( substr ( $ this -> url , 0 , 7 ) == 'mailto:' ) { $ this -> url = \ String :: encodeEmail ( $ this -> url ) ; } else { $ this -> url = ampersand ( $ this -> url ) ; } if ( $ this -> linkTitle == '' ) { $ this -> linkTitle = $ this -> url ; } if ( strncmp ( $ this -> rel , 'lightbox... | compile button element inspired by ContentHyperlink |
13,149 | static function smartUnserialize ( string $ data ) { try { $ value = @ unserialize ( $ data ) ; } catch ( \ Throwable $ e ) { throw new DeserializationFailedException ( 'An exception was thrown during unserialization' , 0 , $ e ) ; } if ( $ value === false && $ data !== self :: getSerializedFalse ( ) ) { throw new Dese... | Attempt to unserialize the given data and properly handle any error states |
13,150 | private function getStockItemId ( $ prodId , $ stockId ) { $ query = $ this -> qbGetStockItem -> build ( ) ; $ conn = $ query -> getConnection ( ) ; $ bind = [ OwnQbGetStockItem :: BND_PROD_ID => $ prodId , OwnQbGetStockItem :: BND_STOCK_ID => $ stockId ] ; $ result = $ conn -> fetchOne ( $ query , $ bind ) ; return $ ... | Get stock item ID by product ID & stock ID . |
13,151 | public function attr ( $ key , $ value = null ) { if ( is_array ( $ key ) ) { foreach ( $ key as $ k => $ val ) $ this -> attributes [ $ k ] = $ val ; return $ this ; } elseif ( $ value === null ) { $ this -> attributeString [ ] = $ key ; return $ this ; } if ( $ key == 'class' ) return $ this -> addClass ( $ value ) ;... | Set input attribute |
13,152 | protected function buildAttributes ( ) { $ attrs = array ( ) ; $ class = '' ; if ( count ( $ this -> classes ) > 0 ) $ class = 'class="' . implode ( ' ' , $ this -> classes ) . '" ' ; if ( count ( $ this -> attributeString ) > 0 ) $ attrs = $ this -> attributeString ; foreach ( $ this -> attributes as $ key => $ value ... | Build input attribute Also build input class attribtue |
13,153 | public function getValue ( ) { $ value = $ this -> override ? : ( isset ( $ this -> attributes [ 'value' ] ) ? $ this -> attributes [ 'value' ] : null ) ; return $ value ; } | Get input value . |
13,154 | public function createClient ( Tenant $ tenant , array $ config = [ ] , $ class = null ) { if ( null === $ class ) { $ class = $ this -> clientClass ; } $ pool = new TokenPool ( $ tenant , $ this -> cache , $ this -> logger ) ; $ signer = new RequestSigner ( $ pool ) ; $ stack = HandlerStack :: create ( ) ; $ stack -> ... | Creates a Guzzle client for communicating with a Keystone service . |
13,155 | public function composeCsv ( array $ data = [ ] , int $ status = 200 , array $ config = [ ] ) : SymfonyResponse { $ filename = $ config [ 'filename' ] ?? 'export' ; $ collection = $ this -> convertToCsvable ( $ data , $ config ) ; return Response :: make ( $ collection -> toCsv ( ) , $ status , [ 'Content-Type' => 'tex... | Compose CSV . |
13,156 | public function streamCsv ( array $ data = [ ] , $ status = 200 , array $ config = [ ] ) : SymfonyResponse { $ filename = $ config [ 'filename' ] ?? 'export' ; $ collection = $ this -> convertToCsvable ( $ data , $ config ) ; return Response :: stream ( function ( ) use ( $ collection ) { $ collection -> streamCsv ( ) ... | Stream CSV . |
13,157 | public function create ( $ appUserId , MoneyOut $ MoneyOut ) { $ url = sprintf ( $ this -> getCreateUrlPattern ( $ MoneyOut ) , $ appUserId ) ; return $ this -> createObject ( $ url , $ MoneyOut ) ; } | Create new money out |
13,158 | public function setUid ( string $ source_tag , int $ max_uid_length = 255 , bool $ connect_onload = false , bool $ connect_onchange = false ) { if ( ! $ source_tag ) { $ this -> uid = false ; return $ this ; } $ this -> uid = [ ] ; $ this -> uid [ 'source' ] = $ source_tag ; if ( ! $ max_uid_length ) { $ this -> uid [ ... | Enables UID function to change non - latin chars to latin |
13,159 | public function generate ( InputInterface $ input , OutputInterface $ output ) : void { $ projectDir = $ this -> container -> getParameter ( 'kernel.project_dir' ) ; $ legacyExtensionDir = $ projectDir . '/src/AppBundle/ezpublish_legacy/app' ; $ siteAccessList = $ input -> getOption ( 'site-access-list' ) ; $ allSiteAc... | Generates the siteaccesses . |
13,160 | public static function destroySessionIfNotAllowed ( ) { if ( ! self :: isAllowedSession ( ) && ini_get ( "session.use_cookies" ) && session_status ( ) == PHP_SESSION_ACTIVE ) { $ params = session_get_cookie_params ( ) ; setcookie ( session_name ( ) , '' , time ( ) - 42000 , $ params [ "path" ] , $ params [ "domain" ] ,... | Destroys session and session cookies if it is started and not allowed |
13,161 | public function validateProperties ( array $ properties ) : bool { foreach ( $ properties as $ property => $ allowed ) { $ this -> validateProperty ( $ property , $ allowed ) ; } return true ; } | Validate an array of properties |
13,162 | public function validateProperty ( string $ property , $ allowed ) : bool { if ( is_string ( $ allowed ) ) { $ allowed = explode ( '|' , $ allowed ) ; } if ( ! is_array ( $ allowed ) ) { throw new InvalidTypeException ( '$allowed must be a string or array' ) ; } $ valid = false ; $ optional = in_array ( 'optional' , $ ... | Validate the property against its allowed types |
13,163 | protected function validatePropertyType ( string $ property , string $ type ) : bool { list ( $ type , $ arg ) = $ this -> parseType ( $ type ) ; switch ( $ type ) { case 'any' : case 'notnull' : case 'isset' : case 'set' : return true ; case 'string' : return is_string ( $ this -> { $ property } ) ; case 'email' : ret... | Check property is valid against type |
13,164 | protected function throwInvalidTypeException ( string $ property , array $ types , bool $ optional = false ) { $ str = "Expected '{{types}}' for {{optional}} property '{{property}}' in {{class}}, got '{{actualtype}}'" ; throw new InvalidTypeException ( Str :: format ( $ str , [ 'types' => trim ( str_replace ( 'optional... | Throw exception when invalid type detected |
13,165 | protected function getRecaptchaResult ( ) { $ response = $ this -> guzzle -> request ( 'POST' , 'https://www.google.com/recaptcha/api/siteverify' , [ 'timeout' => 2.0 , 'query' => [ 'secret' => $ this -> config -> get ( 'antispam.recaptcha.secret' , '' ) , 'response' => $ this -> request -> get ( 'g-recaptcha-response'... | Perform curl request |
13,166 | protected function generatePaginatedResponse ( $ resources , array $ metadada = [ ] ) { $ paginationData = $ this -> generatePaginationData ( $ resources ) ; $ data = [ 'data' => $ this -> transformer -> transformCollection ( $ resources -> items ( ) ) , ] ; return Response :: json ( array_merge ( $ metadada , $ pagina... | Generated a paginated Response |
13,167 | protected function generatePaginationData ( $ resources ) { $ paginationData = [ 'total' => $ resources -> total ( ) , 'per_page' => $ resources -> perPage ( ) , 'current_page' => $ resources -> currentPage ( ) , 'last_page' => $ resources -> lastPage ( ) , 'previous_page_url' => $ resources -> previousPageUrl ( ) , 'n... | Generate the pagination Data . |
13,168 | public function activateInvitation ( ) { $ this -> getInvitationToken ( ) -> delete ( ) ; $ this -> updateLogin ( ) ; $ this -> trackTime ( 'activated_at' ) ; $ this -> setStatus ( Status :: ACTIVE ) ; } | Activate a user from an invitation . |
13,169 | public function run ( ) { if ( $ this -> hide ) { return '' ; } switch ( $ this -> type ) { case self :: FIELD_TYPE_TEXT : { $ instance = $ this -> getInstance ( FieldTypeText :: class ) ; break ; } case self :: FIELD_TYPE_TEXT_AREA : { $ instance = $ this -> getInstance ( FieldTypeTextArea :: class ) ; break ; } case ... | Starts the output widget of the required form field depending on the type of field . |
13,170 | protected function getInstance ( string $ className ) { $ config = [ 'class' => $ className , 'name' => $ this -> name , 'form' => $ this -> form , 'model' => $ this -> model , 'label' => $ this -> label , 'data' => $ this -> data , 'options' => $ this -> options , 'preset' => $ this -> preset , ] ; if ( $ this -> lang... | Creates an object from the class of the selected field widget . |
13,171 | protected function getLabel ( ) : string { if ( $ this -> label != null ) { return $ this -> label ; } if ( isset ( $ this -> model -> attributeLabels ( ) [ $ this -> name ] ) ) { return $ this -> model -> attributeLabels ( ) [ $ this -> name ] ; } return ucfirst ( $ this -> name ) ; } | Returns the label of the field . |
13,172 | protected function getFieldName ( ) : string { if ( $ this -> language === null ) { return $ this -> name ; } return $ this -> name . '_' . strtolower ( $ this -> language -> getShortName ( ) ) ; } | Returns the name of the field tag with the language . |
13,173 | public function val ( $ val = null ) { $ val = ( int ) $ val ; if ( $ val ) { if ( is_numeric ( $ val ) && is_int ( $ val * 1 ) ) { if ( in_array ( $ this -> sources [ $ val ] , $ this -> sources ) ) { $ this -> val = $ val ; return $ this -> val ; } } else { throw new \ SimplOn \ DataValidationException ( $ this -> va... | function val - This function verifies if the value introduced is an integer if isn t throw an exception . |
13,174 | function showView ( $ template = null ) { if ( $ this -> val === null ) { return $ this -> sources = '' ; } else { return $ this -> sources [ $ this -> val ( ) ] ; } } | function showView - This function shows the option selected in the select . |
13,175 | public function init ( ) { $ filter_slug = $ this -> currentPage ; if ( ! empty ( $ this -> options [ 'sections' ] ) && is_array ( $ this -> options [ 'sections' ] ) ) { foreach ( $ this -> options [ 'sections' ] as $ sectionSlug => $ sectionName ) { if ( $ sectionSlug !== $ this -> currentSection ) { continue ; } $ fi... | Initialize menu pages . |
13,176 | public function renderFields ( ) { $ this -> saveFields ( ) ; $ pageCurrent = $ this -> currentPage ; $ sectionCurrent = $ this -> currentSection ; $ formFields = $ this -> fields ; $ contentOptions = $ this -> options ; $ u_link = 'page=' . $ pageCurrent ; $ u_section = ! empty ( $ sectionCurrent ) ? '§ion=' . $ s... | Get section fields . |
13,177 | public function saveFields ( ) { if ( empty ( $ this -> fields ) ) { return ; } $ ids = [ ] ; foreach ( $ this -> fields as $ field ) { if ( ! $ field ) { continue ; } $ ctn = ( array ) $ field -> getModel ( ) -> getContents ( ) ; $ hasId = ( boolean ) $ field -> getModel ( ) -> getHasId ( ) ; if ( $ hasId && ( ! isset... | Set section fields . |
13,178 | public function saveFiles ( $ ids ) { $ files = $ _FILES ; if ( empty ( $ files ) || empty ( $ ids ) ) { return ; } require_once ABSPATH . 'wp-admin' . S . 'includes' . S . 'image.php' ; require_once ABSPATH . 'wp-admin' . S . 'includes' . S . 'file.php' ; require_once ABSPATH . 'wp-admin' . S . 'includes' . S . 'media... | Save files . |
13,179 | public function saveRequest ( $ ids ) { $ request = $ _POST ; if ( empty ( $ request ) || empty ( $ ids ) || ! isset ( $ request [ 'updated' ] ) || 'true' !== $ request [ 'updated' ] ) { return ; } foreach ( $ request as $ k => $ v ) { if ( in_array ( $ k , [ 'updated' , 'submit' ] ) || ! in_array ( $ k , $ ids ) ) { c... | Save request . |
13,180 | public function getAttributeKeys ( $ class = null ) { foreach ( $ this as $ key => $ data ) { if ( $ class ) { if ( $ data instanceof $ class ) $ ret [ ] = $ key ; } else { $ ret [ ] = $ key ; } } return $ ret ; } | Returns the Keys of the Object attributes . |
13,181 | public function labelValue ( $ label , $ value , $ verboseLvl = null , $ insertNewline = true ) { $ this -> simple ( '<strong>' . $ label . ' :</strong> ' . $ value , $ verboseLvl , $ insertNewline ) ; } | Output a value associated to a label . |
13,182 | private function title ( $ title , $ type , $ verboseLvl = null ) { $ this -> simple ( '<' . $ type . '>' . $ title . '</' . $ type . '>' , $ verboseLvl , false ) ; } | Output a title . |
13,183 | private function modeEcho ( $ msg , $ verboseLvl , $ insertNewline , $ dump , $ error ) { if ( $ this -> verbose >= $ verboseLvl ) { if ( $ dump !== false ) { echo '<fieldset style="margin-top:10pt;font-family:' . self :: FONT_FAMILY . ';">' . '<legend style="font-weight:bold;">' . $ msg . '</legend>' . cwsDump ( $ dum... | Output a message in stdout . |
13,184 | private function modeFile ( $ msg , $ verboseLvl , $ insertNewline , $ dump , $ error ) { $ handle = @ fopen ( $ this -> filePath , 'a+' ) ; if ( $ this -> verbose >= $ verboseLvl ) { if ( $ dump !== false ) { fwrite ( $ handle , '<fieldset style="margin-top:10pt;font-family:' . self :: FONT_FAMILY . ';"><legend style=... | Output additional msg for debug in file . |
13,185 | public function setFileMode ( $ filePath = './cwsdebug.html' , $ fileClear = false ) { if ( empty ( $ filePath ) ) { $ this -> error ( 'You have to set the file path for debugging in file mode...' , self :: VERBOSE_QUIET ) ; exit ( ) ; } $ this -> filePath = $ filePath ; if ( ! file_exists ( $ this -> filePath ) ) { to... | Set the mode to file . |
13,186 | public function handle ( RegistrationRequest $ request ) { DB :: beginTransaction ( ) ; try { $ user = $ this -> registration -> registerUser ( ) ; } catch ( \ Exception $ exception ) { DB :: rollBack ( ) ; logger ( ) -> error ( $ exception ) ; return redirect ( route ( 'auth.register' ) ) -> with ( 'errors' , $ except... | Handle validating the registration . |
13,187 | public function createForService ( $ serviceName ) { if ( $ this -> _basePath === null ) { throw new ConfigError ( 'Base path was not given' ) ; } $ filename = $ this -> _filenameTemplate ; if ( strpos ( $ filename , self :: PATTERN_SERVICE ) !== false ) { $ filename = str_replace ( self :: PATTERN_SERVICE , $ serviceN... | Create a logger for the service |
13,188 | public function getCreateCallback ( ) { if ( $ this -> _createCallback === null ) { $ this -> _createCallback = function ( $ path ) { return new Dummy ( ) ; } ; } return $ this -> _createCallback ; } | Get callback which will create an adapter |
13,189 | protected function handleOptions ( & $ options ) { if ( is_array ( $ options ) && isset ( $ options [ self :: PARAM_PROFILER ] ) ) { $ this -> setProfilerStatus ( $ options [ self :: PARAM_PROFILER ] ) ; unset ( $ options [ self :: PARAM_PROFILER ] ) ; } } | Handle the oprtions from a constructor |
13,190 | public function currval ( $ type = null ) { $ result = $ this -> getByType ( 'currval' ) ; if ( ! empty ( $ type ) ) { return $ result [ $ type ] ; } return $ result ; } | Get current sequence value |
13,191 | public function featureCapitalPDangit ( ) { foreach ( [ 'comment_text' , 'the_content' , 'the_title' , 'wp_title' ] as $ filter ) { $ priority = has_filter ( $ filter , 'capital_P_dangit' ) ; if ( false !== $ priority ) { remove_filter ( $ filter , 'capital_P_dangit' , $ priority ) ; } } } | Remove the filter that converts Wordpress to WordPress |
13,192 | public function featureEmbeds ( ) { global $ wp ; $ wp -> public_query_vars = array_diff ( $ wp -> public_query_vars , [ 'embed' ] ) ; remove_action ( 'rest_api_init' , 'wp_oembed_register_route' ) ; add_filter ( 'embed_oembed_discover' , '__return_false' ) ; remove_filter ( 'oembed_dataparse' , 'wp_filter_oembed_resul... | Remove embeds integration |
13,193 | public function featureEmojicons ( ) { remove_action ( 'wp_head' , 'print_emoji_detection_script' , 7 ) ; remove_action ( 'admin_print_scripts' , 'print_emoji_detection_script' ) ; remove_action ( 'wp_print_styles' , 'print_emoji_styles' ) ; remove_action ( 'admin_print_styles' , 'print_emoji_styles' ) ; remove_filter ... | Remove emojicons integration |
13,194 | public function featureSelfPingback ( ) { add_action ( 'pre_ping' , function ( & $ links ) { $ home = get_option ( 'home' ) ; foreach ( $ links as $ l => $ link ) { if ( 0 === strpos ( $ link , $ home ) ) { unset ( $ links [ $ l ] ) ; } } } ) ; } | Remove self pingbacks |
13,195 | public function parse ( $ source , array $ options = null ) { $ result = simplexml_load_string ( $ source ) ; if ( $ result === false ) { throw new InvalidContent ( 'Unable to parse the XML content' ) ; } return $ this -> simpleXmlToArray ( $ result ) ; } | Parse the source config into array |
13,196 | protected function simpleXmlToArray ( SimpleXMLElement $ xml ) { $ result = [ ] ; foreach ( $ xml as $ element ) { $ name = $ element -> getName ( ) ; $ content = get_object_vars ( $ element ) ; if ( isset ( $ content [ '@attributes' ] ) ) { if ( isset ( $ content [ '@attributes' ] [ 'value' ] ) ) { $ result [ $ name ]... | COnvert the SimpleXMLElement instance into an array recursively |
13,197 | private function add ( $ key , $ value , $ ttl = 2592000 ) { $ res = self :: $ memcached -> add ( CFG_DOMAIN . $ key , $ value , $ ttl ) ; return $ res ; } | Add new value |
13,198 | public function process ( HTTPRequest $ request , callable $ next ) { if ( Director :: is_cli ( ) ) { return $ next ( $ request ) ; } try { $ request = $ this -> authenticator -> authenticate ( $ request ) ; if ( $ userID = $ request -> getHeader ( 'oauth_user_id' ) ) { Security :: setCurrentUser ( Member :: get ( ) ->... | Process the middleware . |
13,199 | public static function generate ( $ prefix = 'php-tmp-file' , $ suffix = '' ) { $ filename = tempnam ( sys_get_temp_dir ( ) , $ prefix ) ; if ( $ suffix ) { $ i = 0 ; do { $ newFilename = $ filename . $ i ++ . $ suffix ; } while ( file_exists ( $ newFilename ) ) ; rename ( $ filename , $ newFilename ) ; $ filename = $ ... | Creates a temp file with unique filename . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.