idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
57,700 | public static function findOrDefault ( $ param , array $ attributes ) { $ model = self :: findOrNew ( $ param ) ; if ( $ model -> isNewRecord ) { $ model -> set ( $ attributes ) ; } return $ model ; } | Set not found default data |
57,701 | public static function findWithReplace ( $ param , array $ attributes ) { $ model = self :: findOrNew ( $ param ) ; $ model -> set ( $ attributes ) ; return $ model ; } | Set new attr |
57,702 | public function setTimeout ( int $ seconds , int $ microseconds = 0 ) : self { $ this -> timeout = ( float ) ( $ seconds . '.' . $ microseconds ) ; stream_set_timeout ( $ this -> resource , $ seconds , $ microseconds ) ; return $ this ; } | set timeout for connections |
57,703 | public function read ( int $ length = null ) : string { $ data = null === $ length ? fgets ( $ this -> resource ) : fgets ( $ this -> resource , $ length ) ; if ( false === $ data ) { if ( $ this -> eof ( ) ) { return '' ; } if ( stream_get_meta_data ( $ this -> resource ) [ 'timed_out' ] ) { throw new Timeout ( 'Readi... | read from socket |
57,704 | public function readBinary ( int $ length = 1024 ) : string { $ data = fread ( $ this -> resource , $ length ) ; if ( false === $ data ) { if ( stream_get_meta_data ( $ this -> resource ) [ 'timed_out' ] ) { throw new Timeout ( 'Reading of ' . $ length . ' bytes failed: timeout of ' . $ this -> timeout . ' seconds exce... | read binary data from socket |
57,705 | public function write ( string $ data ) : int { $ length = fputs ( $ this -> resource , $ data , strlen ( $ data ) ) ; if ( false === $ length ) { if ( stream_get_meta_data ( $ this -> resource ) [ 'timed_out' ] ) { throw new Timeout ( 'Writing of ' . strlen ( $ data ) . ' bytes failed:' . ' timeout of ' . $ this -> ti... | write data to socket |
57,706 | public function strainAction ( ) { $ id = $ this -> getRequest ( ) -> get ( $ this -> admin -> getIdParameter ( ) ) ; $ object = $ this -> admin -> getObject ( $ id ) ; $ strain = clone $ object ; $ strain -> setIsStrain ( true ) ; $ strain -> setParent ( $ object ) ; $ fieldSets = [ 'Professional' , 'Amateur' , 'Produ... | Creates a strain from a variety and passes it to create action . |
57,707 | public function getFilterWidgetAction ( Request $ request ) { $ translator = $ this -> get ( 'translator' ) ; $ fieldSet = $ request -> get ( 'fieldset' ) ; $ field = $ request -> get ( 'field' ) ; $ config = $ this -> admin -> getConfigurationPool ( ) -> getContainer ( ) -> getParameter ( 'librinfo_varieties' ) ; $ fi... | Get field widget for filter form . |
57,708 | public function handleErrors ( $ severity , $ message , $ filepath , $ line ) { if ( error_reporting ( ) == 0 || $ severity == E_STRICT ) return ; if ( false !== strpos ( $ filepath , '/' ) ) { $ x = explode ( '/' , $ filepath ) ; $ filepath = $ x [ count ( $ x ) - 3 ] . '/' . $ x [ count ( $ x ) - 2 ] . '/' . end ( $ ... | Defines the error handler that will be used when this class is created . |
57,709 | public function handleExceptions ( $ exception ) { $ this -> displayError ( $ exception ) ; $ this -> sendErrorNotification ( $ exception ) ; if ( isset ( $ this -> ApplicationContext ) && ( $ this -> ApplicationContext -> isOneOffRedeploy ( ) || $ this -> redeployOnError ) ) $ this -> ApplicationContext -> clearContex... | Defines the exception handler to use . |
57,710 | public static function matchLanguage ( $ a , $ b ) { $ a = explode ( '-' , $ a ) ; $ b = explode ( '-' , $ b ) ; for ( $ i = 0 , $ n = min ( count ( $ a ) , count ( $ b ) ) ; $ i < $ n ; $ i ++ ) { if ( $ a [ $ i ] !== $ b [ $ i ] ) break ; } return $ i === 0 ? 0 : ( float ) $ i / count ( $ a ) ; } | compare two language tags and distinguish the degree of matching |
57,711 | protected function paramHasContent ( array $ params , string $ method = 'getStream' ) : bool { if ( ! array_key_exists ( self :: ARRAY_KEY , $ params ) ) { throw new \ RuntimeException ( sprintf ( 'The "%s::%s" expect a file array key to build an instance of FileInfoStreamAdapter' , static :: class , $ method ) ) ; } r... | Param has content |
57,712 | protected function contentIsFileInfo ( $ file , string $ method = 'getStream' ) : bool { if ( ! $ file instanceof \ SplFileInfo ) { $ message = 'The "%s::%s" expect the file array key to be an instance of "%s". "%s" given' ; $ givenType = ( is_object ( $ file ) ? get_class ( $ file ) : gettype ( $ file ) ) ; throw new ... | Content is FileInfo |
57,713 | protected function _filterTag ( $ tag ) { $ isMatch = preg_match ( '~(</?)(\w*)((/(?!>)|[^/>])*)(/?>)~' , $ tag , $ matches ) ; if ( ! $ isMatch ) { return '' ; } $ tagStart = $ matches [ 1 ] ; $ tagName = strtolower ( $ matches [ 2 ] ) ; $ tagAttributes = $ matches [ 3 ] ; $ tagEnd = $ matches [ 5 ] ; if ( ! isset ( $... | Filters a single tag against the current option settings |
57,714 | public function initialize ( Listener $ listener ) { $ this -> listener = $ listener ; $ this -> topDirs = array_merge ( $ this -> topDirs , $ listener -> getPaths ( ) ) ; $ this -> tracker -> initialize ( $ listener ) ; } | Initialize a listener |
57,715 | private function doCleanup ( $ unchecked ) { $ tracker = $ this -> tracker ; foreach ( $ unchecked as $ id => $ tracked ) { $ origin = $ tracked -> getResource ( ) ; if ( ! $ origin -> isExists ( ) ) { $ tracker -> addChangeSet ( $ tracked , FilesystemEvent :: DELETE ) ; $ tracker -> remove ( $ tracked ) ; } unset ( $ ... | Track any undetected changes such as recursive directory delete |
57,716 | final public function authenticateBasic ( $ realm = null ) { if ( ! ( array_key_exists ( 'PHP_AUTH_USER' , $ _SERVER ) and array_key_exists ( 'PHP_AUTH_PW' , $ _SERVER ) ) and ! empty ( $ _SERVER [ 'PHP_AUTH_USER' ] ) and ! empty ( $ _SERER [ 'PHP_AUTH_PW' ] ) ) { $ this -> HTTPAuthenticate ( 'Basic' , array ( 'realm' ... | Checks for credentials in HTTP headers for Basic authentication |
57,717 | public function hasAnnotation ( $ name ) { $ result = false ; if ( ! string_ends_with ( $ name , 'Annotation' ) ) $ name .= 'Annotation' ; foreach ( $ this -> annotations as $ annotation ) { $ class = get_class ( $ annotation ) ; if ( string_starts_with ( $ class , "\\" ) && ! string_starts_with ( $ name , "\\" ) ) $ n... | Tells if the reflection object has the given annotation or not . |
57,718 | public function getAnnotation ( $ name ) { $ result = null ; if ( $ this -> hasAnnotationAndReturn ( $ name ) ) { if ( ! string_ends_with ( $ name , 'Annotation' ) ) $ name .= 'Annotation' ; $ result = isset ( $ this -> annotations [ $ name ] ) ? $ this -> annotations [ $ name ] : null ; if ( $ result == null ) { if ( ... | Returns the requested annotation . |
57,719 | public function isActiveSession ( ) { $ sessionConfig = $ GLOBALS [ 'app' ] -> getConfiguration ( ) -> getRawConfiguration ( 'session' ) ; if ( ! empty ( $ sessionConfig ) && isset ( $ sessionConfig [ 'timeout' ] ) && ! empty ( $ sessionConfig [ 'timeout' ] ) ) { $ sessionTimeout = $ sessionConfig [ 'timeout' ] ; } els... | Checks if session is currently active . |
57,720 | public static function resetActiveSession ( ) { $ appContext = rtrim ( $ GLOBALS [ 'app' ] -> getConfiguration ( ) -> getApplicationContext ( ) , '.' ) ; if ( empty ( $ appContext ) ) { $ appContext = "/" ; } else { $ appContext = "/" . $ appContext . "/" ; } $ category = $ _SESSION [ self :: GLOBAL_PREFIX . 'category'... | Resets currently active session . |
57,721 | public function sqlCheckIntegrity ( $ check = true , $ schema = '' , $ table = '' ) { if ( empty ( $ schema ) && empty ( $ table ) ) { return 'SET CONSTRAINTS ALL ' . ( $ check ? 'IMMEDIATE' : 'DEFERRED' ) ; } return sprintf ( 'ALTER TABLE %s.%s %s TRIGGER ALL' , $ this -> getQuotedName ( $ table ) , $ this -> getQuote... | Builds a SQL statement for enabling or disabling integrity check . |
57,722 | public function addCookie ( $ name , $ value , $ expire = 0 , $ path = '/' , $ domain = '' , $ secure = false , $ httpOnly = true ) { return ( new CookieInjector ) -> build ( ) -> set ( $ name , $ value , $ expire , $ path , $ domain , $ secure , $ httpOnly ) ; } | Add data into cookie |
57,723 | public function generateDescription ( $ paragraph = true ) { if ( ! isset ( $ this -> args [ 'desc' ] ) || ! $ this -> args [ 'desc' ] ) return ; $ tag = ( ! ! $ paragraph || $ paragraph == 'p' ) ? 'p' : 'span' ; return sprintf ( '<%1$s class="description">%2$s</%1$s>' , $ tag , $ this -> args [ 'desc' ] ) ; } | Generate the field description |
57,724 | protected function implodeOptions ( $ method = 'select_option' , $ default = null ) { $ this -> args [ 'default' ] ? : $ this -> args [ 'default' ] = $ default ; $ method = $ this -> camelCase ( $ method ) ; $ method = method_exists ( $ this , $ method ) ? $ method : 'selectOption' ; $ i = 0 ; if ( $ method === 'single... | Implode multi - field items |
57,725 | protected function normalize ( array $ defaults = [ ] , $ implode = false ) { $ args = $ this -> mergeAttributesWith ( $ defaults ) ; $ normalize = new Normalizer ; return ( $ this -> element && method_exists ( $ normalize , $ this -> element ) ) ? $ normalize -> { $ this -> element } ( $ args , $ implode ) : ( ! ! $ i... | Normalize attributes for this specific field type |
57,726 | protected function multiInput ( $ optionKey , $ number , $ type = 'radio' ) { $ args = $ this -> multiInputArgs ( $ type , $ optionKey , $ number ) ; if ( ! $ args ) return ; $ attributes = '' ; foreach ( $ args [ 'attributes' ] as $ key => $ val ) { $ attributes .= sprintf ( '%s="%s" ' , $ key , $ val ) ; } return spr... | Generate checkboxes and radios |
57,727 | protected function selectOption ( $ optionKey ) { return sprintf ( '<option value="%s"%s>%s</option>' , $ optionKey , selected ( $ this -> args [ 'value' ] , $ optionKey , false ) , $ this -> args [ 'options' ] [ $ optionKey ] ) ; } | Generate select options |
57,728 | protected function singleInput ( $ type = 'checkbox' ) { $ optionKey = key ( $ this -> args [ 'options' ] ) ; $ args = $ this -> multiInputArgs ( $ type , $ optionKey , 1 ) ; if ( ! $ args ) return ; $ atts = $ this -> normalize ( ) ; $ atts = wp_parse_args ( $ args [ 'attributes' ] , $ atts ) ; $ attributes = '' ; for... | Generate a single checkbox |
57,729 | public function setColumns ( array $ columns ) { foreach ( $ columns [ 'add' ] as $ key => $ value ) { $ this -> dataTables -> addColumn ( $ key , $ value ) ; } foreach ( $ columns [ 'edit' ] as $ key => $ value ) { $ this -> dataTables -> editColumn ( $ key , $ value ) ; } foreach ( $ columns [ 'remove' ] as $ value )... | set data table columns |
57,730 | private function getDefaultUrls ( $ model ) { $ slug = getModelSlug ( $ model ) ; return [ 'details' => lmbRoute ( "api.{$slug}.detail" , [ 'id' => $ model -> id ] ) , 'fast_edit' => lmbRoute ( "api.{$slug}.fastEdit" , [ 'id' => $ model -> id ] ) , 'edit' => lmbRoute ( "api.{$slug}.update" , [ 'id' => $ model -> id ] )... | get default urls for Datatables |
57,731 | public function setShow ( $ show ) { Argument :: i ( ) -> test ( 1 , 'int' ) ; if ( $ show < 1 ) { $ show = 1 ; } $ this -> show = $ show ; return $ this ; } | Sets pages to show left and right of the current page |
57,732 | public function toSQL ( Parameters $ params , bool $ inner_clause ) { if ( $ key = $ this -> getKey ( ) ) { try { $ params -> get ( $ key ) ; } catch ( \ OutOfRangeException $ e ) { $ key = null ; } } if ( ! $ key ) $ key = $ params -> assign ( null ) ; $ this -> bind ( $ params , $ key , array ( $ params -> getDriver ... | Write a constant array clause as SQL query syntax |
57,733 | public function getName ( array $ keys = [ ] , string $ delimiter = "." ) : string { if ( empty ( $ keys ) ) { return $ this -> name ; } $ keys [ ] = $ this -> name ; return implode ( $ delimiter , $ keys ) ; } | Get the name of the field |
57,734 | public function getNestedName ( string $ delimiter = "." , string $ name = "" ) : string { $ keys = array_filter ( [ $ this -> name , $ name ] , "strlen" ) ; $ parent = $ this ; while ( $ parent = $ parent -> getParent ( ) ) { $ name = $ parent -> getName ( ) ; if ( $ name ) { array_unshift ( $ keys , $ parent -> getNa... | Get a field s nested name |
57,735 | public function getTransport ( $ transportName ) { if ( empty ( $ this -> transport [ $ transportName ] ) ) { throw new InvalidArgumentException ( sprintf ( 'Transport %s not found' , $ transportName ) ) ; } return $ this -> transport [ $ transportName ] ; } | Get transport by name |
57,736 | public function add ( $ path , $ handler ) { $ route = new Route ( $ path , $ handler ) ; $ this -> routes [ ] = $ route ; $ this -> nameCache = [ ] ; $ this -> routeParser = new RouteParser ; return $ route ; } | Adds a route to the map and resets the name cache . |
57,737 | private function buildNameCache ( ) { if ( ! empty ( $ this -> nameCache ) ) { return ; } foreach ( $ this as $ route ) { if ( ! $ route -> name ( ) ) { continue ; } $ this -> nameCache [ $ route -> name ( ) ] = $ route ; } } | Iterates through routes and builds a name cache . |
57,738 | public function setJsonOptions ( $ options ) { $ this -> encodingOptions = ( int ) $ options ; return $ this -> setData ( $ this -> getData ( ) ) ; } | Set the JSON encoding options . |
57,739 | public static function initiate ( $ settings ) { $ taskStatus = new BackgroundTaskStatus ( ) ; $ taskStatus -> TaskClass = get_called_class ( ) ; $ taskStatus -> TaskSettings = $ settings ; $ taskStatus -> save ( ) ; $ task = new static ( ) ; $ additionalArguments = $ task -> getShellArguments ( ) ; $ additionalArgumen... | Initiates execution of the background task . |
57,740 | public function add ( \ SplFileInfo $ file ) { $ content = new \ Org_Heigl \ FileFinder \ Service \ Tokenlist ( file_get_contents ( $ file -> getPathname ( ) ) ) ; $ classname = $ content -> getClassName ( ) ; if ( ! $ classname ) { return ; } $ class = $ content -> getNamespace ( ) ; $ class [ ] = $ classname ; $ key ... | Add an SPL - File - Info to the filelist |
57,741 | public function call ( ) { $ params = $ this -> app -> router ( ) -> getCurrentRoute ( ) -> getParams ( ) ; $ options = $ this -> model -> getOptionsList ( ) ; if ( isset ( $ params [ 'id' ] ) ) { $ options = $ this -> model -> getOptions ( ) ; } if ( in_array ( $ this -> app -> request ( ) -> getMethod ( ) , $ options... | Check if the current HTTP method is allowed for the resource being accesed |
57,742 | public function getMD ( $ content ) { $ funcArr = [ "yamlfrontmatter" , "shortcode" , "markdown" , "titlefromheader" ] ; $ textFilter = new textFilter ( ) ; return $ textFilter -> parse ( $ content , $ funcArr ) -> text ; } | Return markdown based on string |
57,743 | protected function getFeed ( $ query , $ options ) { $ options = array_merge ( [ 'query' => $ query ] , $ options ) ; $ nyaa = $ this -> getNyaa ( ) ; $ feed = $ nyaa -> getFeed ( $ options ) ; $ matcher = $ this -> getMatcher ( ) ; return array_filter ( $ feed , function ( $ item ) use ( $ matcher , $ query ) { $ titl... | Gets the torrent feed for given query and options |
57,744 | public function filterDuplicates ( $ torrents ) { $ arr = [ ] ; foreach ( $ torrents as $ torrent ) { $ arr [ $ torrent -> getTorrentId ( ) ] = $ torrent ; } return array_values ( $ arr ) ; } | Return list with unique torrents from given array |
57,745 | public function mapByHash ( $ feed ) { $ torrents = [ ] ; foreach ( $ feed as $ torrent ) { $ hash = $ torrent -> getSeriesHash ( ) ; if ( ! isset ( $ torrents [ $ hash ] ) ) { $ torrents [ $ hash ] = new NyaaSet ( $ hash ) ; } $ torrents [ $ hash ] -> add ( $ torrent ) ; } return $ torrents ; } | Maps the torrents by series hash and collects them in a NyaaSet |
57,746 | public function collectForUser ( $ query , $ users , $ options = [ ] ) { $ bigFeed = [ ] ; foreach ( $ users as $ userId ) { $ userOptions = array_merge ( $ options , [ 'user' => $ userId ] ) ; $ userFeed = $ this -> getFeed ( $ query , $ userOptions ) ; $ bigFeed = array_merge ( $ bigFeed , $ userFeed ) ; } $ bigFeed ... | Searches for torrents per user |
57,747 | public function collectRecursive ( $ query , $ options = [ ] ) { $ feed = $ this -> getFeed ( $ query , $ options ) ; $ userIds = [ ] ; foreach ( $ feed as $ torrent ) { if ( ! isset ( $ userIds [ $ torrent -> getSeriesHash ( ) ] ) ) { $ userIds [ $ torrent -> getSeriesHash ( ) ] = $ torrent -> getUserId ( ) ; } } $ us... | Searches for torrent and searches for each found torrent in their user for more torrents to create complete sets |
57,748 | public function collect ( $ query , $ options = [ ] ) { if ( ! $ this -> getNyaa ( ) -> canProvideAllData ( ) ) { return $ this -> collectRecursive ( $ query , $ options ) ; } return $ this -> collectSingleFeed ( $ query , $ options ) ; } | Searches for torrents by query and returns sets created from it Collects recursively if backend doesn t provide all data |
57,749 | public function collectSingleFeed ( $ query , $ options = [ ] ) { $ feed = $ this -> getFeed ( $ query , $ options ) ; return $ this -> mapByHash ( $ feed ) ; } | Searches for torrents by query and returns sets created from it only fetches one feed . |
57,750 | private function getDwnlCustomer ( ) { if ( is_null ( $ this -> cacheDwnlCust ) ) { $ custId = $ this -> session -> getCustomerId ( ) ; $ this -> cacheDwnlCust = $ this -> daoDwnlCust -> getById ( $ custId ) ; } return $ this -> cacheDwnlCust ; } | Cached data for current downline customer . |
57,751 | public function actionTranslation ( $ options ) { if ( ! is_array ( $ options ) ) { return $ this -> translator -> trans ( $ options , [ ] , 'CmsKernelAdminBridge' ) ; } $ resultOptions = [ ] ; foreach ( $ options as $ optionKey => $ option ) { $ option = null === json_decode ( $ option , true ) ? $ option : json_decod... | Callback of action translation Twig filter that returns resultant array . |
57,752 | public function reverseTransform ( $ boolean ) { if ( ! $ boolean ) { return null ; } $ rClass = new \ ReflectionClass ( $ this -> specificationClass ) ; if ( $ rClass -> getConstructor ( ) && $ rClass -> getConstructor ( ) -> getNumberOfParameters ( ) > 0 ) { return $ rClass -> newInstanceArgs ( $ this -> constructorA... | Transforms a value into a specification . |
57,753 | public static function detectEnv ( array $ environments , $ uri ) { foreach ( $ environments as $ environment => $ patterns ) { foreach ( $ patterns as $ pattern ) { if ( Inflector :: is ( $ pattern , $ uri ) or $ pattern == gethostname ( ) ) { return $ environment ; } } } } | Detect the current environment from an environment configuration . |
57,754 | public function setEntry ( $ var = null , $ val = null , $ section = false ) { if ( ! empty ( $ var ) ) { if ( $ section ) { if ( ! isset ( $ this -> registry [ $ section ] ) ) { $ this -> registry [ $ section ] = array ( ) ; } $ this -> registry [ $ section ] [ $ var ] = $ val ; } else { $ this -> registry [ $ var ] =... | Set an entry in the instance registry |
57,755 | public function getEntry ( $ var = null , $ section = false , $ default = null ) { if ( ! empty ( $ var ) ) { if ( ! empty ( $ section ) && isset ( $ this -> registry [ $ section ] ) && isset ( $ this -> registry [ $ section ] [ $ var ] ) ) { return $ this -> registry [ $ section ] [ $ var ] ; } elseif ( isset ( $ this... | Get an entry from the instance registry |
57,756 | public function isEntry ( $ var = null , $ section = false ) { return ( ! empty ( $ var ) and ( ( ! empty ( $ section ) && isset ( $ this -> registry [ $ section ] ) && isset ( $ this -> registry [ $ section ] [ $ var ] ) ) or isset ( $ this -> registry [ $ var ] ) ) ) ; } | Check if an entry exists in registry |
57,757 | public function getKey ( $ val = null , $ var = null , $ section = false ) { if ( ! empty ( $ val ) ) { if ( ! empty ( $ var ) ) { foreach ( $ this -> registry as $ _sct => $ _data ) { if ( $ ok = array_search ( $ val , $ _data ) && $ ok == $ var ) { return $ _sct ; } } } elseif ( ! empty ( $ section ) && isset ( $ thi... | Search a key in registry |
57,758 | public function dumpStack ( $ index = null , $ default = null ) { if ( array_key_exists ( $ index , $ this -> registry_stacks ) ) { return $ this -> registry_stacks [ $ index ] ; } return $ default ; } | Get a full stack from registry stacks |
57,759 | public function saveStack ( $ index = null , $ and_clean = false ) { $ this -> registry_stacks [ $ index ] = $ this -> registry ; if ( $ and_clean === true ) { $ this -> registry = array ( ) ; } return $ this ; } | Save a stack of entries in registry |
57,760 | public function getStackEntry ( $ var = null , $ section = false , $ stack = null , $ default = null ) { if ( ! empty ( $ var ) ) { if ( ! empty ( $ stack ) && $ this -> isStack ( $ stack ) ) { $ tmp_stack = $ this -> registry ; $ this -> loadStack ( $ stack ) ; $ val = $ this -> getEntry ( $ var , $ section , $ defaul... | Get a stack entry of the registry stacks |
57,761 | public function getStackKey ( $ val = null , $ section = false , $ stack = null , $ default = null ) { if ( ! empty ( $ val ) ) { if ( ! empty ( $ stack ) && $ this -> isStack ( $ stack ) ) { $ tmp_stack = $ this -> registry ; $ this -> loadStack ( $ stack ) ; $ var = $ this -> getKey ( $ val , $ section , $ default ) ... | Get the key of a stack entry of the registry stacks |
57,762 | public function create ( Description $ description ) { return new Tip ( new Identifier ( $ description -> getMandatoryProperty ( 'id' ) ) , $ description -> getMandatoryProperty ( 'text' ) , $ description -> getMandatoryProperty ( 'type' ) , $ description -> getMandatoryProperty ( 'agreeCount' ) , $ description -> getM... | Create a tip from a description . |
57,763 | public static function getMimeType ( $ filePath ) { $ fInfo = finfo_open ( FILEINFO_MIME_TYPE ) ; $ mime = finfo_file ( $ fInfo , $ filePath ) ; finfo_close ( $ fInfo ) ; return $ mime ; } | Get mime - type og the file . |
57,764 | private static function createInstance ( $ classname , array $ arguments = array ( ) ) { $ reflection_obj = new ReflectionClass ( $ classname ) ; if ( $ reflection_obj -> getMethod ( '__construct' ) -> isPublic ( ) ) { self :: $ _instances [ $ classname ] = call_user_func_array ( array ( $ reflection_obj , 'newInstance... | Real object instances creation |
57,765 | public function linkModels ( Models $ models , Models $ foreign , Closure $ yield ) { foreach ( $ models as $ model ) { $ linked = [ ] ; foreach ( $ foreign as $ foreignModel ) { if ( $ this -> areLinked ( $ model , $ foreignModel ) ) { $ linked [ ] = $ foreignModel ; } } $ link = $ this -> newLinkFrom ( $ model , $ li... | Iterate models and foreign models one by one and and assign links based on the areLinked method Yeild the resulted links one by one for further processing . |
57,766 | public function getEnabledLinks ( ) { switch ( $ this -> LinkMode ) { case self :: MODE_PAGES : $ links = ArrayList :: create ( ) ; foreach ( $ this -> LinkedPages ( ) as $ page ) { $ link = $ page -> toLink ( ) ; $ link -> setParent ( $ this ) ; $ links -> push ( $ link ) ; } break ; default : $ links = $ this -> getL... | Answers a list of the enabled links within the receiver . |
57,767 | public function addIfExists ( $ file_path , $ media = 'screen' , $ condition = null ) { $ _fp = $ this -> __template -> findAsset ( $ file_path ) ; if ( $ _fp || \ AssetsManager \ Loader :: isUrl ( $ file_path ) ) { return $ this -> add ( $ file_path , $ media , $ condition ) ; } return $ this ; } | Add a CSS file in CSS stack if it exists |
57,768 | public function add ( $ file_path , $ media = 'screen' , $ condition = null ) { $ _fp = $ this -> __template -> findAsset ( $ file_path ) ; if ( $ _fp || \ AssetsManager \ Loader :: isUrl ( $ file_path ) ) { $ this -> registry -> addEntry ( array ( 'file' => $ _fp , 'media' => $ media , 'condition' => $ condition ) , '... | Add a CSS file in CSS stack |
57,769 | public function set ( array $ files ) { if ( ! empty ( $ files ) ) { foreach ( $ files as $ _file ) { if ( is_array ( $ _file ) && isset ( $ _file [ 'file' ] ) ) { $ this -> add ( $ _file [ 'file' ] , isset ( $ _file [ 'media' ] ) ? $ _file [ 'media' ] : '' , isset ( $ _file [ 'condition' ] ) ? $ _file [ 'condition' ] ... | Set a full CSS stack |
57,770 | public function addMerged ( $ file_path , $ media = 'screen' ) { $ _fp = $ this -> __template -> findAsset ( $ file_path ) ; if ( $ _fp || \ AssetsManager \ Loader :: isUrl ( $ file_path ) ) { $ this -> registry -> addEntry ( array ( 'file' => $ _fp , 'media' => $ media ) , 'css_merged_files' ) ; } else { throw new \ I... | Add an merged file |
57,771 | public function writeMinified ( $ mask = '%s' ) { $ str = '' ; foreach ( $ this -> cleanStack ( $ this -> getMinified ( ) , 'file' ) as $ entry ) { $ tag_attrs = array ( 'rel' => 'stylesheet' , 'type' => 'text/css' , 'href' => $ entry [ 'file' ] ) ; if ( isset ( $ entry [ 'media' ] ) && ! empty ( $ entry [ 'media' ] ) ... | Write minified versions of the files stack in the cache directory |
57,772 | protected function form ( Model $ model ) { $ this -> breadcrumb -> onItem ( $ model ) ; return app ( 'antares.form' ) -> of ( 'awesone-module-form' , function ( FormGrid $ form ) use ( $ model ) { $ form -> name ( 'My Awesome Module Form' ) ; $ form -> resourced ( 'antares::sample_module/index' , $ model ) ; $ form ->... | Generowanie nowego obiektu formularza |
57,773 | public function store ( ) { $ input = Input :: all ( ) ; $ user = auth ( ) -> user ( ) ; $ attributes = [ 'user_id' => $ user -> hasRoles ( 'member' ) ? $ user -> id : array_get ( $ input , 'user' ) , 'name' => array_get ( $ input , 'name' ) , 'value' => array_only ( $ input , [ 'field_1' , 'field_2' ] ) ] ; $ model = ... | When stores form fields in database |
57,774 | public function update ( $ id ) { $ model = ModuleRow :: withoutGlobalScopes ( ) -> findOrFail ( $ id ) ; if ( ! request ( ) -> isMethod ( 'put' ) ) { $ form = $ this -> form ( $ model ) ; } else { $ input = Input :: all ( ) ; $ user = auth ( ) -> user ( ) ; if ( ! $ user -> hasRoles ( 'member' ) ) { $ model -> user_id... | When updates form fields in database |
57,775 | public function delete ( $ id ) { $ builder = ModuleRow :: withoutGlobalScopes ( ) ; if ( auth ( ) -> user ( ) -> hasRoles ( 'member' ) ) { $ builder -> where ( [ 'user_id' => auth ( ) -> user ( ) -> id ] ) ; } $ model = $ builder -> findOrFail ( $ id ) ; $ name = $ model -> name ; if ( $ model -> delete ( ) ) { event ... | When deletes item |
57,776 | public function cast ( $ model ) { if ( $ model instanceof Collection ) { return $ model -> map ( [ $ this , 'cast' ] ) -> toArray ( ) ; } if ( empty ( $ model ) ) { return ; } $ transformed = [ ] ; foreach ( $ this -> castRules ( ) as $ old => $ desired ) { $ this -> resolveCast ( $ old , $ desired , $ model , $ trans... | Casts collection fields . |
57,777 | private function resolveCast ( $ old , $ desired , Model $ model , & $ transformed ) { if ( $ desired instanceof Closure ) { return $ transformed [ $ old ] = call_user_func ( $ desired , $ model ) ; } if ( is_string ( $ desired ) && strpos ( $ desired , $ this -> functionSign ) !== false ) { return $ transformed [ $ ol... | Resolves casts based on supplied array of arguments . |
57,778 | protected function render ( ) { if ( null === $ this -> active ) { $ this -> setActive ( key ( $ this -> tabs ) ) ; } $ tabs = new ViewModel ; $ tabs -> tabs = $ this -> tabs ; $ tabs -> setTemplate ( 'sxbootstrap/tabs/tabs' ) ; return $ this -> getView ( ) -> render ( $ tabs ) ; } | Renders the tabs and returns the markup . |
57,779 | public function add ( $ label , $ content = null , $ tabId = null , $ active = false ) { $ tabId = is_null ( $ tabId ) ? $ this -> getTabId ( ) : $ tabId ; $ label = is_null ( $ label ) ? $ tabId : $ label ; $ this -> tabs [ $ tabId ] = array ( 'label' => $ label , 'content' => $ content , 'active' => $ active , ) ; re... | Add a new tab . |
57,780 | protected function getTabId ( $ current = false ) { if ( true === $ current ) { return key ( $ this -> tabs ) ; } $ c = $ this -> tabCount ++ ; return $ this -> defaultTabIdentifier . $ c ; } | Generate an id for a tab or get the last added one . |
57,781 | public function query ( ) { if ( $ this -> result === null ) { $ this -> before_called = true ; foreach ( $ this -> before_query as $ callable ) { $ callable ( ) ; } try { $ this -> result = $ this -> query -> query ( ) ; $ this -> result -> setFetchMode ( \ PDO :: FETCH_ASSOC ) ; } catch ( \ Smalldb \ Flupdo \ FlupdoS... | Execute SQL query or do whatever is required to get this listing populated . |
57,782 | public function fetchAll ( ) { if ( $ this -> result === null ) { $ this -> query ( ) ; } $ machine = $ this -> machine ; $ id_keys = $ this -> machine -> describeId ( ) ; if ( count ( $ id_keys ) == 1 ) { $ list = array ( ) ; while ( ( $ properties = $ this -> result -> fetch ( \ PDO :: FETCH_ASSOC ) ) ) { $ item = $ ... | Returns an array of all items in the listing . |
57,783 | protected function calculateAdditionalFiltersData ( & $ filters ) { if ( ! empty ( $ this -> additional_filters_data ) ) { foreach ( $ this -> additional_filters_data as $ f => $ src ) { if ( isset ( $ src [ 'query' ] ) ) { $ filters [ $ f ] = $ this -> query -> pdo -> query ( $ src [ 'query' ] ) -> fetchColumn ( ) ; }... | Calculate additional filter data . |
57,784 | protected function setupSphinxSearch ( $ filter_name , $ value , $ machine_filter ) { $ sphinx_key_column = $ this -> query -> quoteIdent ( $ machine_filter [ 'sphinx_key_column' ] ) ; $ temp_table = $ this -> query -> quoteIdent ( '_sphinx_temp_' . $ filter_name ) ; $ index_name = $ this -> query -> quoteIdent ( $ mac... | Setup query for lookup in Sphinx search engine . |
57,785 | public function setValue ( $ value ) { switch ( $ this -> type ) { case self :: TYPE_BOOLEAN : $ this -> value = ( bool ) $ value ; break ; case self :: TYPE_STRING : $ this -> value = ( string ) $ value ; break ; } return $ this ; } | Option value setter |
57,786 | public function send ( ConversionInterface $ conversion ) : ResponseInterface { if ( ! $ conversion instanceof Conversion ) { throw new UnsupportedConversionTypeException ( $ this , $ conversion ) ; } $ previousSentConversion = $ this -> repository -> pull ( $ conversion -> getId ( ) , get_class ( $ conversion ) ) ; if... | Sending POST query to CPA network after creating conversion |
57,787 | public function getPersister ( $ key ) { if ( empty ( $ key ) || false === $ this -> hasPersister ( $ key ) ) { throw PersisterException :: persisterNotFound ( $ key ) ; } return $ this -> persisters [ $ key ] ; } | Gets a Persister service by key . |
57,788 | public function getSearchClient ( $ key ) { if ( empty ( $ key ) || false === $ this -> hasSearchClient ( $ key ) ) { throw ClientException :: clientNotFound ( $ key ) ; } return $ this -> searchClients [ $ key ] ; } | Gets a Search Client service by key . |
57,789 | public function check ( $ hostname ) { $ result = array ( ) ; foreach ( $ this -> getBlServers ( ) as $ blServer ) { $ result [ ] = $ blServer -> getResolver ( ) -> execute ( $ hostname ) ; } return $ result ; } | Check hostname in all bl servers |
57,790 | public function checkIP ( $ ip ) { $ result = array ( ) ; foreach ( $ this -> getBlServers ( ) as $ blServer ) { if ( $ blServer -> supportIPv4 ( ) ) { $ result [ ] = $ blServer -> getResolver ( ) -> execute ( $ ip ) ; } } return $ result ; } | Check IP in black list |
57,791 | public function checkDomain ( $ hostname ) { $ result = array ( ) ; foreach ( $ this -> getBlServers ( ) as $ blServer ) { if ( $ blServer -> supportDomain ( ) ) { $ result [ ] = $ blServer -> getResolver ( ) -> execute ( $ hostname ) ; } } return $ result ; } | Check domain name in black list |
57,792 | public function set ( array $ tags ) { if ( ! empty ( $ tags ) ) { foreach ( $ tags as $ _tag ) { $ this -> add ( $ _tag ) ; } } return $ this ; } | Set a full links header stack |
57,793 | public function getImageStorage ( $ image ) { if ( @ file_exists ( 'file://' . $ image ) ) { return DriverInterface :: IMAGE_STORAGE_FILE ; } elseif ( false === strpos ( $ image , '://' ) ) { return DriverInterface :: IMAGE_STORAGE_STRING ; } else { return DriverInterface :: IMAGE_STORAGE_URL ; } } | Get storage type of image |
57,794 | public function getInfo ( $ image ) { if ( DriverInterface :: IMAGE_STORAGE_STRING == $ this -> getImageStorage ( $ image ) ) { $ image = 'data://application/octet-stream;base64,' . base64_encode ( $ image ) ; } return getimagesize ( $ image ) ; } | Get info of image |
57,795 | public function ensure ( $ image , $ formats , $ storages ) { $ storage = $ this -> getImageStorage ( $ image ) ; $ format = $ this -> getImageFormat ( $ image ) ; $ storages = is_string ( $ storages ) ? array ( $ storages ) : $ storages ; $ formats = is_int ( $ formats ) ? array ( $ formats ) : $ formats ; if ( in_arr... | Ensure certain image storages und formats |
57,796 | protected function getFileOptionForSaving ( $ storages ) { if ( in_array ( DriverInterface :: IMAGE_STORAGE_STRING , $ storages ) ) { return null ; } elseif ( in_array ( DriverInterface :: IMAGE_STORAGE_FILE , $ storages ) ) { return sys_get_temp_dir ( ) . '/tmp-image-' . rand ( ) ; } else { throw new Exception \ Runti... | Get file option from storages for saving |
57,797 | public function loadToString ( $ image ) { $ srcStorage = $ this -> getImageStorage ( $ image ) ; if ( $ srcStorage !== DriverInterface :: IMAGE_STORAGE_STRING ) { $ image = @ file_get_contents ( $ image ) ; if ( false === $ image ) { throw new Exception \ RuntimeException ( 'could not load image' ) ; } } return $ imag... | Load image to string |
57,798 | public function saveFromString ( $ image , $ options = array ( ) ) { if ( isset ( $ options [ 'file' ] ) ) { if ( false === @ file_put_contents ( $ options [ 'file' ] , $ image ) ) { throw new Exception \ RuntimeException ( 'could not save image' ) ; } return $ options [ 'file' ] ; } return $ image ; } | Save image from string |
57,799 | public function getAllowedDbValues ( array $ except = [ ] ) { $ map = $ this -> getMap ( ) ; $ dbValues = array_diff ( array_keys ( $ map ) , $ except ) ; return $ dbValues ; } | Returns list of the all registered database values |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.