idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
2,700 | public function addGroup ( Communicator $ communicator , ProcessedGroup $ group ) : ProcessedMembership { $ response = $ communicator -> post ( 'api/memberships' , new Membership ( $ group -> getID ( ) , $ this -> contactID ) ) ; $ returnValue = RecipientFactory :: createProcessedMembershipFromJSON ( $ response ) ; if ... | Adds the contact to the given group and returns the membership . |
2,701 | public static function classToName ( $ class , $ type ) { if ( ! class_exists ( $ class ) ) { throw new InvalidArgumentException ( "Class '" . $ class . "' not found!" ) ; } $ class = self :: _trimNamespace ( $ class ) ; if ( ! isset ( self :: $ masks [ $ type ] ) ) { throw new InvalidArgumentException ( "Invalid mask ... | Converts class to name |
2,702 | public static function nameToClass ( $ name , $ type ) { if ( ! isset ( self :: $ masks [ $ type ] ) ) { throw new InvalidArgumentException ( "Invalid mask type " . $ type . "!" ) ; } return str_replace ( "*" , $ name , self :: $ masks [ $ type ] ) ; } | Converts name to class |
2,703 | protected function addScript ( $ name , $ from = AssetsInterface :: ASSETS_JS , array $ dependencies = [ 'jquery' ] , $ version = '1.0.0' , $ inFooter = true , $ ajaxUrl = null ) { wp_enqueue_script ( $ name , $ this -> path ( $ from , $ name ) , $ dependencies , $ version , $ inFooter ) ; if ( null !== $ ajaxUrl ) { $... | Method that wraps the WordPress internal wp_enqueue_script simplifying the process adding some common default values . |
2,704 | protected function addStylesheet ( $ name , $ from = AssetsInterface :: CSS , array $ dependencies = [ ] , $ version = '1.0.0' , $ media = 'all' ) { wp_enqueue_style ( $ name , $ this -> path ( $ from , $ name , 'css' ) , $ dependencies , $ version , $ media ) ; return $ this ; } | Method that wraps the WordPress internal wp_enqueue_style simplifying the process adding some common default values . |
2,705 | protected function registerAjaxUrls ( $ name , $ ajaxUrl ) { if ( false === is_array ( $ ajaxUrl ) ) { $ ajaxUrl = [ $ ajaxUrl ] ; } foreach ( $ ajaxUrl as $ url ) { wp_localize_script ( $ name , $ url , [ 'ajaxUrl' => admin_url ( 'admin-ajax.php' ) , ] ) ; } } | Registers the ajax urls inside given JS filename . |
2,706 | protected function pdepend ( $ path ) { $ jsonGenerator = new JsonGenerator ( ) ; $ jsonGenerator -> setLogFile ( $ path . DIRECTORY_SEPARATOR . $ this -> json ) ; $ application = new Application ( ) ; $ config = $ application -> getConfiguration ( ) ; $ config -> cache -> driver = 'file' ; $ config -> cache -> locatio... | Runs pdepend to generate the metrics . |
2,707 | public function createComponentZip ( ) { $ comZip = new \ ZipArchive ( JPATH_BASE . "/dist" , \ ZipArchive :: CREATE ) ; $ tmp_path = '/dist/tmp/cbuild' ; if ( file_exists ( JPATH_BASE . $ tmp_path ) ) { $ this -> _deleteDir ( JPATH_BASE . $ tmp_path ) ; } $ this -> _mkdir ( JPATH_BASE . $ tmp_path ) ; $ this -> _copyD... | Create a installable zip file for a component |
2,708 | public function createLibraryZips ( ) { $ path = $ this -> current . "/libraries" ; $ hdl = opendir ( $ path ) ; while ( $ lib = readdir ( $ hdl ) ) { $ p = $ path . "/" . $ lib ; if ( substr ( $ lib , 0 , 1 ) == '.' ) { continue ; } if ( substr ( $ lib , 0 , 3 ) != "lib" ) { $ lib = 'lib_' . $ lib ; } if ( ! is_file (... | Create zips for libraries |
2,709 | public function createModuleZips ( ) { $ path = $ this -> current . "/modules" ; $ hdl = opendir ( $ path ) ; while ( $ entry = readdir ( $ hdl ) ) { $ p = $ path . "/" . $ entry ; if ( substr ( $ entry , 0 , 1 ) == '.' ) { continue ; } if ( ! is_file ( $ p ) ) { $ this -> say ( "Packaging Module " . $ entry ) ; $ zip ... | Create zips for modules |
2,710 | public function createPluginZips ( ) { $ path = $ this -> current . "/plugins" ; $ hdl = opendir ( $ path ) ; while ( $ entry = readdir ( $ hdl ) ) { $ p = $ path . "/" . $ entry ; if ( substr ( $ entry , 0 , 1 ) == '.' ) { continue ; } if ( ! is_file ( $ p ) ) { $ type = $ entry ; $ hdl2 = opendir ( $ p ) ; while ( $ ... | Create zips for plugins |
2,711 | public function translate ( $ key , $ package = 'default' , $ locale = '' , $ default = null ) { $ defaultLocale = Locale :: getDefault ( ) ; $ locale = $ locale ? : Locale :: get ( ) ; $ locale = $ locale ? : $ defaultLocale ; $ translation = null ; $ fallbackList = LocaleHelper :: getLocaleFallbackList ( $ locale , $... | Get a translation value . If there is no value for the given locale it tries to fallback to default locale . If the default value is null and no translation is found it throws Exception . |
2,712 | protected function getValue ( $ field ) { $ value = null ; $ readField = 'get' . $ field ; foreach ( $ this -> readProfiles as $ profile ) { $ value = $ profile -> $ readField ( ) ; if ( $ value !== null ) { $ this -> setValue ( $ field , $ value ) ; break ; } } return $ value ; } | Searches all profiles for the given value |
2,713 | private function purgeRecurse ( $ dir ) { $ base = $ dir . '/' ; $ time = time ( ) ; if ( substr ( $ dir , 0 , strlen ( $ this -> dir ) ) !== $ this -> dir ) { assert ( 0 ) ; return ; } foreach ( scandir ( $ dir ) as $ f ) { $ fn = $ base . $ f ; if ( $ f [ 0 ] === '.' ) { continue ; } if ( is_dir ( $ fn ) ) { $ this -... | Purges the contents of a directory recursively |
2,714 | protected function generateClassName ( $ tableName , $ short = false ) { $ ns = null ; if ( list ( $ prefix , $ ns ) = $ this -> tablePrefixMatches ( $ tableName ) ) { $ tableName = substr ( $ tableName , strlen ( $ prefix ) ) ; } $ className = parent :: generateClassName ( $ tableName ) ; if ( null !== $ ns && $ short... | Generates a class name with namespace prefix from the specified table name . |
2,715 | public static function fromPairs ( $ array ) { if ( ! is_array ( $ array ) && ! ( $ array instanceof \ Traversable ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Dictionary::fromPairs() argument must be array or Traversable, ' . 'but is "%s".' , gettype ( $ array ) ) ) ; } $ result = new Dictionary ( ) ; forea... | Create new Dictionary from array of key - value pairs . |
2,716 | public static function fromArray ( $ array ) { if ( ! is_array ( $ array ) && ! ( $ array instanceof \ Traversable ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Dictionary::fromArray() argument must be array or Traversable, ' . 'but is "%s".' , gettype ( $ array ) ) ) ; } $ result = new Dictionary ( ) ; forea... | Create new Dictionary from standard PHP array . |
2,717 | public function toPairs ( ) { $ result = [ ] ; foreach ( $ this as $ key => $ value ) { $ result [ ] = [ $ key , $ value ] ; } return $ result ; } | Get array of all key - value pairs in dictionary . |
2,718 | public function sortBy ( $ callback = null , $ direction = 'ASC' ) { if ( ! is_callable ( $ callback ) ) { if ( is_null ( $ callback ) or is_string ( $ callback ) && 'values' === strtolower ( $ callback ) ) { $ callback = function ( $ value , $ key ) { return $ value ; } ; } else if ( is_string ( $ callback ) && 'keys'... | Sort Dictionary by values returned by callback . |
2,719 | private function handle ( $ handler , $ parameters ) { if ( $ handler instanceof \ Closure ) { $ this -> app -> execute ( $ handler , $ parameters ) ; } else { list ( $ controller , $ action ) = explode ( '@' , $ handler ) ; $ class = $ this -> app -> construct ( $ controller ) ; $ this -> app -> execute ( [ $ class , ... | Handler for route found support Closure and Controller methods . |
2,720 | public static function createFromConfig ( array $ config ) { $ fields = [ ] ; foreach ( $ config as $ name => $ field ) { $ fields [ $ name ] = Fields :: create ( $ name , $ field ) ; } return new static ( $ fields ) ; } | Method to create form fieldset object and fields from config |
2,721 | public function setCurrent ( $ i ) { $ this -> current = ( int ) $ i ; if ( ! isset ( $ this -> fields [ $ this -> current ] ) ) { $ this -> fields [ $ this -> current ] = [ ] ; } return $ this ; } | Method to get current group index |
2,722 | public function insertFieldAfter ( $ name , Element \ AbstractElement $ field ) { foreach ( $ this -> fields as $ i => $ group ) { $ fields = [ ] ; foreach ( $ group as $ key => $ value ) { if ( $ key == $ name ) { $ fields [ $ key ] = $ value ; $ fields [ $ field -> getName ( ) ] = $ field ; } else { $ fields [ $ key ... | Method to insert a field after another one |
2,723 | public function count ( ) { $ count = 0 ; foreach ( $ this -> fields as $ group ) { $ count += count ( $ group ) ; } return $ count ; } | Method to get the count of elements in the form fieldset |
2,724 | public function hasField ( $ name ) { $ result = false ; foreach ( $ this -> fields as $ key => $ fields ) { if ( isset ( $ fields [ $ name ] ) ) { $ result = true ; break ; } } return $ result ; } | Method to determine if the fieldset has a field |
2,725 | public function getFields ( $ i ) { return ( isset ( $ this -> fields [ $ i ] ) ) ? $ this -> fields [ $ i ] : null ; } | Method to get field element objects in a group |
2,726 | public function getAllFields ( ) { $ fields = [ ] ; foreach ( $ this -> fields as $ group ) { foreach ( $ group as $ field ) { $ fields [ $ field -> getName ( ) ] = $ field ; } } return $ fields ; } | Method to get all field elements |
2,727 | public function prepareForView ( ) { $ fields = [ ] ; foreach ( $ this -> fields as $ groups ) { foreach ( $ groups as $ field ) { if ( null !== $ field -> getLabel ( ) ) { $ labelFor = $ field -> getName ( ) . ( ( $ field -> getNodeName ( ) == 'fieldset' ) ? '1' : '' ) ; $ label = new Child ( 'label' , $ field -> getL... | Prepare fieldset elements for rendering with a view |
2,728 | public function getUserModel ( ) { $ model = Config :: get ( 'auth.model' ) ; if ( class_exists ( $ model ) ) { return $ model ; } $ ns = $ this -> getAppNamespace ( ) ; if ( $ ns ) { $ model = $ ns . 'User' ; if ( class_exists ( $ model ) ) { return $ model ; } $ model = $ ns . 'Models\User' ; if ( class_exists ( $ mo... | Gets the user model if found . |
2,729 | public function createGuest ( ) { $ model = $ this -> getUserModel ( ) ; if ( $ model ) { $ guest = new $ model ( ) ; $ guest -> name = 'Guest' ; $ guest -> email = 'guest@example.com' ; } else { $ guest = ( object ) [ 'name' => 'Guest' , 'email' => 'guest@example.com' ] ; } return $ guest ; } | Return an instance of a guest user uses user model if exists . |
2,730 | public static function getVersion ( $ path , $ strict = false ) { $ version = 'unknown' ; $ temp_path = getcwd ( ) ; chdir ( $ path ) ; do { $ descriptorspec = array ( 0 => array ( 'pipe' , 'r' ) , 1 => array ( 'pipe' , 'w' ) , 2 => array ( 'pipe' , 'w' ) , ) ; $ process = proc_open ( 'git describe' , $ descriptorspec ... | Determine the git version based on git describe and semver conventions . |
2,731 | public function afterFind ( ) { if ( $ this -> autoFetchProperties === true ) { $ owner = $ this -> owner ; $ owner -> ensurePropertyGroupIds ( ) ; $ models = [ & $ owner ] ; PropertiesHelper :: fillProperties ( $ models ) ; } return true ; } | Performs auto fetching properties if it is turned on |
2,732 | public function beforeDelete ( ) { $ owner = $ this -> owner ; $ event = new HasPropertiesEvent ( ) ; $ event -> model = $ owner ; HasPropertiesEvent :: trigger ( self :: class , self :: EVENT_BEFORE_DELETE , $ event ) ; $ array = [ & $ owner ] ; PropertiesHelper :: deleteAllProperties ( $ array ) ; unset ( $ array ) ;... | Deletes related properties from database |
2,733 | public function hasPropertyKey ( $ key ) { $ owner = $ this -> owner ; $ owner -> ensurePropertiesAttributes ( ) ; return in_array ( $ key , $ owner -> propertiesAttributes ) ; } | Returns if property is binded to model |
2,734 | public function afterInsert ( ) { $ owner = $ this -> owner ; $ groups = $ owner -> propertyGroupIds ; $ owner -> propertyGroupIds = null ; $ event = new HasPropertiesEvent ( ) ; $ event -> model = $ owner ; HasPropertiesEvent :: trigger ( self :: class , self :: EVENT_AFTER_SAVE , $ event ) ; if ( count ( $ groups ) >... | Performs after insert stuff |
2,735 | public function indexAction ( ) { $ optionsProvider = $ this -> getOptionsProvider ( ) ; if ( $ this -> getRequest ( ) -> isPost ( ) ) { $ event = $ this -> request -> getPost ( 'suboperation' ) ; if ( ! empty ( $ event ) ) { $ events = $ this -> getEventManager ( ) ; $ params = $ this -> request -> getPost ( ) ; $ res... | Show content list . |
2,736 | public function searchAction ( ) { $ optionsProvider = $ this -> getOptionsProvider ( ) ; $ pane = $ this -> params ( ) -> fromRoute ( 'pane' ) ; if ( ! $ pane || ! $ optionsProvider -> hasIdentifier ( $ pane ) ) { $ pane = 'first' ; } $ options = $ optionsProvider -> getOptions ( $ pane , 'search' ) ; $ search = $ opt... | Show search options . |
2,737 | public static function nearestColor ( $ refLabs , $ lab , $ algorithm , $ returnArrayKey = false , $ cacheKey = "" ) { $ subKey = $ lab [ 0 ] . $ lab [ 1 ] . $ lab [ 2 ] ; $ result = array ( ) ; if ( empty ( $ cacheKey ) || ! isset ( static :: $ nearestColors [ $ cacheKey ] ) || ! isset ( static :: $ nearestColors [ $ ... | Searches a list of colors for the one with the shortest distance to a given color |
2,738 | public function fetch ( $ key ) { $ key = $ this -> get_key ( $ key ) ; return wp_cache_get ( $ key , $ this -> group ) ; } | Fetch cache data . |
2,739 | public function save ( $ key , $ value , $ expire = 0 ) { $ key = $ this -> get_key ( $ key ) ; wp_cache_set ( $ key , $ value , $ this -> group , $ expire ) ; } | Save cache data . |
2,740 | public function getFormatter ( ) { $ fmt = $ this -> settings -> format ; $ formatter = null ; if ( ! is_string ( $ fmt ) && is_subclass_of ( $ fmt , 'Luminous\\Formatters\\Formatter' ) ) { $ formatter = clone $ fmt ; } elseif ( $ fmt === 'html' ) { $ formatter = new HtmlFormatter ( ) ; } elseif ( $ fmt === 'html-inlin... | Returns an instance of the current formatter |
2,741 | public function highlight ( $ scanner , $ source , $ settings = null ) { $ oldSettings = null ; if ( $ settings !== null ) { if ( ! is_array ( $ settings ) ) { throw new Exception ( 'Luminous internal error: Settings is not an array' ) ; } $ oldSettings = clone $ this -> settings ; foreach ( $ settings as $ k => $ v ) ... | The real highlighting function |
2,742 | public function persistence ( $ provider , array $ params = array ( ) ) { $ this -> persistence = array_merge ( array ( Config :: PROVIDER => $ provider ) , array ( Config :: PARAMS => $ params ) ) ; return $ this ; } | Set persistence provider |
2,743 | public function cache ( $ provider , array $ params = array ( ) ) { $ this -> cache = array_merge ( array ( config :: PROVIDER => $ provider ) , array ( Config :: PARAMS => $ params ) ) ; return $ this ; } | Set Cache provider |
2,744 | public function logDir ( $ dir ) { $ this -> logDir = $ dir ; $ this -> buildFileLogger ( $ this -> logDir ) ; return $ this ; } | Set logging directory |
2,745 | protected static function getResolvedClassInstance ( ) { $ classNamespace = static :: getStaticClassAccessor ( ) ; $ resolvedClassInstance = self :: getClass ( $ classNamespace ) ; if ( ! $ resolvedClassInstance ) { return self :: resolveClassNameSpace ( $ classNamespace ) ; } return $ resolvedClassInstance ; } | Check if the class namespace already have a cached resolved instance if not then the class namespace must be resolve . |
2,746 | protected static function resolveClassNameSpace ( $ classNamespace ) { if ( ! \ is_string ( $ classNamespace ) ) { throw ClassNamespaceResolverException :: isNotString ( ) ; } if ( ! \ class_exists ( $ classNamespace ) ) { throw ClassNamespaceResolverException :: isNotExist ( ) ; } $ classNamespace = self :: classNames... | Resolver for service class namespace . Set the resolved service class instance to the class property . |
2,747 | private function _initType ( $ definition ) { if ( isset ( self :: $ typeAliases [ $ definition ] ) ) { $ definition = self :: $ typeAliases [ $ definition ] ; } if ( self :: isScalarType ( $ definition ) || in_array ( $ definition , [ self :: TYPE_ARRAY , self :: TYPE_DATE , self :: TYPE_DATETIME ] , true ) ) { $ this... | Initialize property type |
2,748 | public function convertValue ( $ value ) { if ( $ value === null || ( $ value === "" && $ this -> type !== self :: TYPE_STRING ) ) { return ; } if ( self :: isScalarType ( $ this -> type ) || $ this -> type === self :: TYPE_ARRAY ) { if ( $ this -> type === self :: TYPE_BOOLEAN && strtolower ( $ value ) === "false" ) {... | Try to convert value on required type automatically |
2,749 | protected function renderNamespace ( $ ns , $ directives ) { $ ret = '' ; $ ret .= $ this -> start ( 'tbody' , array ( 'class' => 'namespace' ) ) ; $ ret .= $ this -> start ( 'tr' ) ; $ ret .= $ this -> element ( 'th' , $ ns , array ( 'colspan' => 2 ) ) ; $ ret .= $ this -> end ( 'tr' ) ; $ ret .= $ this -> end ( 'tbod... | Renders a single namespace |
2,750 | public function parseJson ( $ json ) { $ this -> mentionName = $ json [ 'mention_name' ] ; $ this -> id = $ json [ 'id' ] ; $ this -> name = $ json [ 'name' ] ; if ( isset ( $ json [ 'links' ] ) ) { $ this -> links = $ json [ 'links' ] ; } if ( isset ( $ json [ 'xmpp_jid' ] ) ) { $ this -> xmppJid = $ json [ 'xmpp_jid'... | Parses response given by the API and maps the fields to User object |
2,751 | public function call ( $ method , $ url , array $ post = array ( ) , array $ headers = array ( ) ) { $ options = array ( CURLOPT_URL => $ url , CURLOPT_RETURNTRANSFER => true , CURLOPT_HTTPHEADER => $ headers , ) ; switch ( $ method ) { case HttpMethod :: GET : $ options [ CURLOPT_POST ] = false ; break ; case HttpMeth... | Do raw HTTP call |
2,752 | public function update ( Entity $ entity , $ primaryValue ) { if ( ! $ entity -> getValidator ( ) -> validate ( ) ) { throw new Exception \ ValidatorException ( $ entity -> getValidator ( ) ) ; } try { if ( ! $ this -> query ( ) -> updateOne ( $ primaryValue , $ entity -> getData ( ) ) -> run ( $ this -> connection ) )... | Update single record |
2,753 | public function destroy ( Entity $ entity ) { $ requiredClass = Convention :: nameToClass ( $ this -> getEntityName ( ) , Convention :: ENTITY_MASK ) ; if ( ! $ entity instanceof $ requiredClass ) { throw new Exception \ RepositoryException ( "Entity must be instance of " . $ requiredClass . "!" ) ; } $ reflection = $ ... | Delete single record |
2,754 | public function find ( array $ filter = [ ] , array $ orderBy = [ ] , $ limit = 0 , $ offset = 0 , array $ associate = [ ] ) { try { $ query = $ this -> query ( ) -> select ( ) -> associate ( $ associate ) -> setFilter ( $ filter ) ; foreach ( $ orderBy as $ orderByRule ) { $ query -> orderBy ( $ orderByRule [ 0 ] , $ ... | Find all records |
2,755 | public function findPrimaries ( array $ primaryValues , array $ associate = [ ] ) { $ reflection = Entity \ Reflection :: load ( $ this -> getEntityName ( ) ) ; if ( ! $ reflection -> hasPrimary ( ) ) { throw new Exception \ RepositoryException ( "Method can not be used because entity " . $ this -> getEntityName ( ) . ... | Find records by set of primary values |
2,756 | public static function collectionContains ( $ needle , $ haystack ) { foreach ( $ haystack as $ value ) { if ( $ value === $ needle ) { return true ; } } return false ; } | Indicates wether given collection contains the wanted item or not . |
2,757 | protected function _initRequest ( $ socket , $ response ) { $ stream = $ this -> _classes [ 'stream' ] ; $ curlOptions = $ socket -> options ( ) ; $ curlOptions [ CURLOPT_INFILESIZE ] = $ socket -> outgoing ( ) -> length ( ) ; if ( isset ( $ curlOptions [ CURLOPT_FILE ] ) ) { $ response -> body ( fopen ( $ curlOptions ... | Initialize a socket to be ready to send data . |
2,758 | public function push ( $ request , $ response , $ options = [ ] ) { $ socket = $ request instanceof $ this -> _classes [ 'socket' ] ? $ request : $ this ( $ request , $ options ) ; $ this -> _queue [ $ socket -> id ( ) ] = [ 'socket' => $ socket , 'response' => $ response ] ; } | Push a request in the queue . |
2,759 | public function flush ( $ max = 10 , $ options = [ ] ) { $ defaults = [ 'selectTimeout' => 1.0 ] ; $ options += $ defaults ; do { $ this -> select ( $ options [ 'selectTimeout' ] ) ; $ this -> process ( $ max ) ; } while ( $ this -> _running > 0 ) ; $ results = $ this -> _results ; $ this -> _results = [ ] ; return $ r... | Runs until all outstanding requests have been completed . |
2,760 | protected function _fillup ( $ max ) { $ nb = $ max - $ this -> _running ; $ list = array_splice ( $ this -> _queue , 0 , $ nb ) ; foreach ( $ list as $ item ) { $ handle = $ this -> _initRequest ( $ item [ 'socket' ] , $ item [ 'response' ] ) ; $ this -> _handles [ ( integer ) $ handle ] = $ item ; curl_multi_add_hand... | Fill the multi handle up to the maximum allowed connections . |
2,761 | public static function rangeThisWeek ( ) { $ ts = strtotime ( date ( 'Y-m-d' ) ) + 86400 ; do { $ ts -= 86400 ; $ startDate = date ( 'N' , $ ts ) ; } while ( $ startDate != '1' ) ; return [ $ ts , $ ts + ( 86400 * 6 ) ] ; } | Returns a date range for the current week . |
2,762 | public static function rangeThisMonth ( ) { $ currentMonth = date ( 'Y-m-01' , time ( ) ) ; $ currentMonthTs = self :: toTs ( $ currentMonth ) ; return [ $ currentMonthTs , $ currentMonthTs + ( 86400 * ( date ( 't' ) - 1 ) ) ] ; } | Returns a date range for the current month . |
2,763 | public static function rangeLastMonth ( ) { $ lastMonth = date ( 'm' ) - 1 ; if ( $ lastMonth <= 0 ) { $ lastMonth = 12 ; } $ lastMonth = date ( 'Y' ) . '-' . $ lastMonth . '-01' ; return [ self :: toTs ( $ lastMonth ) , self :: toTs ( $ lastMonth ) + ( 86400 * ( date ( 't' , strtotime ( $ lastMonth ) ) - 1 ) ) ] ; } | Returns a date range for the previous month . |
2,764 | public static function getAnnotationReader ( ) { if ( self :: $ annotationReader === null ) { self :: $ annotationReader = new CachedReader ( new AnnotationReader ( ) , new ArrayCache ( ) ) ; } return self :: $ annotationReader ; } | Get the annotation reader that is used . Initializes it if it doesn t already exists . |
2,765 | public static function getConstraintsValidator ( ) { if ( self :: $ constraintsValidator === null ) { self :: $ constraintsValidator = Validation :: createValidatorBuilder ( ) -> enableAnnotationMapping ( self :: getAnnotationReader ( ) ) -> getValidator ( ) ; } return self :: $ constraintsValidator ; } | Get the constraints validator that is used . Initializes it if it doesn t already exists . |
2,766 | private static function setCache ( Cache & $ cacheToChange = null , Cache $ cache = null , $ namespace = null ) { if ( $ namespace === null ) { $ namespace = self :: $ cacheDefaultNamespace ; } if ( ! is_string ( $ namespace ) ) { throw new \ InvalidArgumentException ( "The namespace must be a string." ) ; } $ cacheToC... | Set a cache driver . |
2,767 | public static function setCacheDriver ( Cache $ cache = null , $ namespace = null ) { self :: setCache ( self :: $ cacheDriver , $ cache , $ namespace ) ; } | Set the cache driver that will be used . |
2,768 | public static function beNice ( $ strength = self :: ALL_LOWER_CASE , $ lenght = 8 , $ append_numbers = 2 ) { $ password = '' ; $ vocals = self :: EVEN_CHARS ; $ consonants = self :: ODD_CHARS ; if ( $ strength > 0 ) { $ vocals .= strtoupper ( $ vocals ) ; } if ( $ strength > 1 ) { $ consonants .= strtoupper ( $ conson... | Generate a random human readable password . |
2,769 | public static function checkAccess ( $ permissionName , $ user = false , $ params = [ ] ) { if ( is_array ( $ permissionName ) ) { $ permissionName = self :: createPermissionName ( $ permissionName ) ; } if ( ! $ user ) { $ user = Yii :: $ app -> user ; } if ( ! $ user -> isGuest && ! isset ( self :: $ userRoles [ $ us... | Check whether the user has access to permission . |
2,770 | public function move ( $ oldParent , $ newParent ) { return $ oldParent -> removeChild ( $ this ) ? $ newParent -> addChild ( $ this ) : false ; } | Detaches this model from its old parent and attaches to the new one . |
2,771 | public function addChild ( AuthItem $ item ) { if ( $ item -> isNewRecord && ! $ item -> save ( ) ) { return false ; } return Yii :: $ app -> authManager -> addChild ( $ this , $ item ) ; } | Attaches child related to this model by AuthItemChild . |
2,772 | public function eq ( $ str , $ flags = 0 ) { $ ret = false ; if ( list ( $ str ) = $ this -> match ( preg_quote ( $ str , "/" ) , $ matches , $ flags ) ) { $ ret = array ( $ str ) ; } return $ ret ; } | Is the next token equal to a given string? |
2,773 | public function in ( $ items , $ flags = 0 ) { $ ret = false ; usort ( $ items , function ( $ item1 , $ item2 ) { return strlen ( $ item1 ) < strlen ( $ item2 ) ; } ) ; foreach ( $ items as $ item ) { if ( $ this -> eq ( $ item , $ flags ) ) { $ ret = array ( $ item ) ; break ; } } return $ ret ; } | Is the next token the in a given list? |
2,774 | public function number ( $ flags = 0 ) { $ ret = false ; if ( $ number = $ this -> match ( TextTokenizer :: NUMBER , $ matches , $ flags ) ) { $ ret = $ number ; } return $ ret ; } | Is the next token a number? |
2,775 | public function str ( $ flags = 0 ) { $ ret = false ; if ( $ this -> match ( TextTokenizer :: STRING , $ matches , $ flags ) ) { $ delimiter = $ matches [ 2 ] ; $ str = $ matches [ 3 ] ; $ str = str_replace ( "\\$delimiter" , "$delimiter" , $ str ) ; $ ret = array ( $ str ) ; } return $ ret ; } | Is the next token a string? |
2,776 | public function id ( ) { $ ret = false ; if ( list ( $ id ) = $ this -> match ( TextTokenizer :: IDENTIFIER ) ) { $ ret = array ( $ id ) ; } return $ ret ; } | Is the next token an identifier? |
2,777 | public function match ( $ regexp , & $ matches = array ( ) , $ flags = 0 ) { if ( strlen ( $ regexp ) == 0 ) { return false ; } $ ret = false ; $ explicitRegexp = strlen ( $ regexp ) > 0 && $ regexp [ 0 ] == "/" ; $ substr = substr ( $ this -> string , $ this -> offset ) ; if ( ! $ explicitRegexp ) { $ caseSensitive = ... | Matches the string against a regex . |
2,778 | public function isZero ( ) { return ( gmp_sign ( $ this -> value [ 'real' ] -> numerator ( ) -> gmp ( ) ) == 0 && gmp_sign ( $ this -> value [ 'imaginary' ] -> numerator ( ) -> gmp ( ) ) == 0 ) ; } | Is this number equal to zero? |
2,779 | public function forceAuthentication ( ) { if ( self :: isAuthenticated ( ) ) { return true ; } elseif ( $ this -> getTicket ( ) ) { return $ this -> validateCas ( ) ; } session_write_close ( ) ; $ this -> redirectToCas ( ) ; return true ; } | If not authenticated redirect to CAS . If authenticated return true . |
2,780 | public function checkAuthentication ( ) { if ( self :: isAuthenticated ( ) ) { return true ; } elseif ( self :: isGatewayed ( ) ) { return $ this -> validateCas ( ) ; } self :: setGatewayed ( true ) ; session_write_close ( ) ; $ this -> redirectToCas ( true ) ; return true ; } | If not gatewayed redirect to CAS with gateway = true . |
2,781 | protected function redirectToCas ( $ gateway = false ) { $ query [ 'service' ] = self :: getDefaultService ( ) ; if ( $ gateway ) { $ query [ 'gateway' ] = 'true' ; } self :: http_redirect ( $ this -> server [ 'login_url' ] . '?' . http_build_query ( $ query ) ) ; return true ; } | Redirect to CAS server for login |
2,782 | protected static function getDefaultService ( ) { $ service = ( isset ( $ _SERVER [ 'HTTPS' ] ) ? 'https' : 'http' ) . '://' . $ _SERVER [ 'SERVER_NAME' ] . $ _SERVER [ 'REQUEST_URI' ] ; $ parts = parse_url ( $ service ) ; if ( isset ( $ parts [ 'query' ] ) ) { parse_str ( $ parts [ 'query' ] , $ query ) ; } else { $ q... | Get the service name of this request |
2,783 | private function checkPages ( ) { if ( is_null ( $ this -> pageLimit ) ) { return false ; } if ( ++ $ this -> pageCounter > $ this -> pageLimit ) { return true ; } return false ; } | Uses internal counter to check page limit |
2,784 | private function checkTime ( ) { if ( is_null ( $ this -> timeLimit ) ) { return false ; } if ( ( $ this -> startTime + $ this -> timeLimit ) <= time ( ) ) { return true ; } return false ; } | Checks time between first and current request |
2,785 | public function add ( $ key , $ default , $ type , $ allow_null ) { $ obj = new stdclass ( ) ; $ obj -> type = is_int ( $ type ) ? $ type : HTMLPurifier_VarParser :: $ types [ $ type ] ; if ( $ allow_null ) $ obj -> allow_null = true ; $ this -> info [ $ key ] = $ obj ; $ this -> defaults [ $ key ] = $ default ; $ this... | Defines a directive for configuration |
2,786 | public function run ( InputInterface $ input , OutputInterface $ output ) : int { return $ this -> console -> run ( $ input , $ output ) ; } | Runs Console Application . |
2,787 | private function initConsole ( string $ name , string $ version ) { $ this -> console = $ this -> container -> get ( SymfonyConsoleApplication :: class ) ; $ this -> console -> setName ( $ name ) ; $ this -> console -> setVersion ( $ version ) ; $ this -> console -> setCatchExceptions ( false ) ; $ this -> console -> s... | Initiates Symfony Console Application . |
2,788 | public function getAllDevices ( ) { $ devices = array ( ) ; $ devicesId = $ this -> getAllDevicesID ( ) ; foreach ( $ devicesId as $ deviceId ) { $ device = $ this -> getDevice ( $ deviceId ) ; $ devices [ ] = $ device ; } return $ devices ; } | Returns all devices in the repository |
2,789 | public static function getNearestStation ( $ stations , $ coordinatesRequest ) { $ calculator = new Vincenty ( ) ; $ nearestStation = null ; $ nextDist = INF ; foreach ( $ stations as $ activeStation ) { if ( is_object ( $ activeStation ) && $ activeStation instanceof DWDStation ) { $ coordinatesStation = new Coordinat... | Return the nearest stations from a stations array . |
2,790 | public static function getNearestStations ( $ stations , Coordinate $ coordinatesRequest , int $ radiusKM = 200 ) { DWDUtil :: log ( self :: class , "Getting nearest stations from a list of " . count ( $ stations ) . ", around coordinates: " . $ coordinatesRequest -> format ( new DecimalDegrees ( ) ) ) ; $ calculator =... | Get all stations in an x km radius . |
2,791 | public static function getStationFile ( $ stationFtpPath , $ outputPath ) { $ ftpConfig = DWDConfiguration :: getFTPConfiguration ( ) ; $ ftp_connection = ftp_connect ( $ ftpConfig -> url ) ; $ login_result = ftp_login ( $ ftp_connection , $ ftpConfig -> userName , $ ftpConfig -> userPassword ) ; if ( $ login_result &&... | Tries to download the station file from the given path . |
2,792 | public static function parseStations ( $ filePath ) { if ( DIRECTORY_SEPARATOR == '\\' ) $ filePath = str_replace ( '/' , '\\' , $ filePath ) ; ini_set ( 'display_errors' , 1 ) ; error_reporting ( E_ALL ) ; $ stationConf = DWDConfiguration :: getStationConfiguration ( ) ; $ stations = array ( ) ; if ( file_exists ( $ f... | Parse the station files into station objects . |
2,793 | public static function createByName ( $ name ) { $ constants = self :: getConstantsByName ( ) ; if ( ! array_key_exists ( $ name , $ constants ) ) { throw EnumException :: invalidName ( get_called_class ( ) , $ name ) ; } return new static ( $ constants [ $ name ] ) ; } | Creates a new type instance using the name of a value |
2,794 | public static function createByValue ( $ value ) { $ constants = self :: getConstantsByValue ( ) ; if ( ! array_key_exists ( $ value , $ constants ) ) { throw EnumException :: invalidValue ( get_called_class ( ) , $ value ) ; } return new static ( $ value ) ; } | Creates a new type instance using the value |
2,795 | public function parseHourlyDataOld ( String $ content , DWDStation $ nearestStation , Coordinate $ coordinate , Carbon $ startDate = null , Carbon $ endDate = null ) : array { $ time = microtime ( true ) ; $ lines = explode ( 'eor' , $ content ) ; $ data = array ( ) ; DWDUtil :: log ( "PARSER" , "DATE=[" . $ endDate ->... | Parse the textual representation of DWD Data can be filtered by specifying before and after . This means if you specify after - you will get timestamps after the specified team If you also specify before you can pinpoint values . |
2,796 | public function getStationFTPPath ( string $ ftpPath ) { $ fileName = DWDUtil :: getFileNameFromPath ( $ ftpPath ) ; $ filePath = DWDConfiguration :: getConfiguration ( ) -> baseDirectory . DWDConfiguration :: getConfiguration ( ) -> dwdHourly -> localBaseFolder . '/' . $ fileName ; return $ filePath ; } | Return the path to the file that contains the stations . |
2,797 | public function boot ( $ request = null ) { $ this -> getApp ( ) -> boot ( $ request , $ this -> bootstrapRegistry -> getItems ( ) ) ; Controller :: setRouter ( $ this -> getRouter ( ) ) ; include_once $ this -> routesConfiguration -> getRoutesPath ( $ this -> getApp ( ) -> getBasePath ( ) ) ; } | Init the panda application and start all the interfaces that are needed for runtime . |
2,798 | public function handle ( SymfonyRequest $ request ) { $ this -> boot ( $ request ) ; return $ this -> getRouter ( ) -> dispatch ( $ request ) ; } | Handle the incoming request and return a response . |
2,799 | public function setDimension ( $ dimensionName , $ dimensionValue = null ) { $ this -> pipeline [ '$match' ] [ 'name' ] = $ dimensionName ; if ( ! empty ( $ dimensionValue ) ) { $ this -> pipeline [ '$match' ] [ 'value' ] = $ dimensionValue ; } return $ this ; } | Filter the dimension records . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.