idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
10,500 | public function search ( $ search = '' , $ criteria = SORTDATE , $ opt = SE_UID , $ dir = 1 ) { if ( '' === ( $ search = trim ( $ search ) ) ) { $ search = null ; } return imap_sort ( $ this -> stream , $ criteria , $ dir , $ opt , $ search ) ; } | Search mailbox for emails |
10,501 | public static function from ( DriverInterface $ driver , $ message = '' , $ code = 0 , \ Exception $ previous = null ) { $ self = $ message ? ( $ code ? new static ( $ message , $ code , $ previous ) : new static ( $ message ) ) : new static ( ) ; $ self -> setDriver ( $ driver ) ; return $ self ; } | Factory method to set the driver that created this exception . |
10,502 | protected function initStackSession ( ) { $ http = $ this -> getHttpDriver ( ) ; if ( ! $ http -> isSessionStarted ( ) ) { throw new DebugBarException ( 'Session must be started before using stack data in the songshenzong' ) ; } if ( ! $ http -> hasSessionValue ( $ this -> stackSessionNamespace ) ) { $ http -> setSessi... | Initializes the session for stacked data |
10,503 | private function addNamespaceFilter ( ProjectDescriptorBuilder $ builder , Filter $ filterManager ) { $ filter = new LegacyNamespaceFilter ( $ builder ) ; foreach ( $ this -> plugin -> getParameters ( ) as $ param ) { if ( $ param -> getKey ( ) == 'NamespacePrefix' ) { $ filter -> setNamespacePrefix ( $ param -> getVal... | Attaches the filter responsible for the conversion to all structural elements . |
10,504 | private function writeSession ( $ message , $ from = '' , $ is_error = false ) { if ( session_id ( ) ) { $ key = $ is_error ? $ this -> error_key : $ this -> message_key ; if ( ! isset ( $ _SESSION [ $ key ] ) || ! is_array ( $ _SESSION [ $ key ] ) ) { $ _SESSION [ $ key ] = [ ] ; } $ _SESSION [ $ key ] [ ] = ( empty (... | Write message to session |
10,505 | public function flushMessage ( ) { if ( session_id ( ) ) { foreach ( [ $ this -> error_key => 'error' , $ this -> message_key => 'updated' ] as $ key => $ class_name ) { if ( isset ( $ _SESSION [ $ key ] ) && ! empty ( $ _SESSION [ $ key ] ) ) { $ markup = sprintf ( '<div class="%s"><p>%s</p></div>' , $ class_name , im... | Show message on screen |
10,506 | public static function prepare ( $ name , $ source , $ option ) { if ( is_string ( $ option ) ) { $ option = ( array ) Helper :: arrGet ( self :: $ multiples , $ option , array ( ) ) ; } $ lists = self :: find_multiple ( $ name , $ source , $ option ) ; $ found = self :: merge_multiple ( $ option , $ lists ) ; return $... | prepares for validation by creating a value from multiple value . |
10,507 | private static function find_multiple ( $ name , $ source , $ option ) { $ sep = Helper :: arrGet ( $ option , 'separator' , '_' ) ; $ suffix = explode ( ',' , $ option [ 'suffix' ] ) ; $ lists = [ ] ; foreach ( $ suffix as $ sfx ) { $ name_sfx = $ name . $ sep . $ sfx ; if ( array_key_exists ( $ name_sfx , $ source ) ... | find multiples values from suffix list . |
10,508 | private static function merge_multiple ( $ option , $ lists ) { if ( empty ( $ lists ) ) { return null ; } if ( isset ( $ option [ 'format' ] ) ) { $ param = array_merge ( array ( $ option [ 'format' ] ) , $ lists ) ; $ found = call_user_func_array ( 'sprintf' , $ param ) ; } else { $ con = Helper :: arrGet ( $ option ... | merge the found list into one value . |
10,509 | public function to_path ( string $ id ) { if ( bbn \ str :: is_uid ( $ id ) ) { return $ this -> options -> to_path ( $ id , '' , $ this -> _get_public_root ( ) ) ; } return false ; } | Returns the path corresponding to an ID |
10,510 | public function add_shortcut ( string $ id ) : ? string { if ( ( $ bit = $ this -> pref -> get_bit ( $ id , false ) ) && ( $ id_option = $ this -> from_path ( 'shortcuts' ) ) && ( $ c = $ this -> pref -> get_class_cfg ( ) ) ) { if ( $ id_menu = $ this -> pref -> get_by_option ( $ id_option ) ) { $ id_menu = $ id_menu [... | Adds an user shortcut from a menu |
10,511 | public function remove_shortcut ( $ id ) : ? int { if ( \ bbn \ str :: is_uid ( $ id ) ) { return $ this -> pref -> delete_bit ( $ id ) ; } return null ; } | Removes an user shortcut |
10,512 | public function shortcuts ( ) : ? array { if ( ( $ id_option = $ this -> from_path ( 'shortcuts' ) ) && ( $ menu = $ this -> pref -> get_by_option ( $ id_option ) ) ) { $ links = $ this -> pref -> get_bits ( $ menu [ 'id' ] ) ; $ res = [ ] ; foreach ( $ links as $ link ) { if ( ( $ url = $ this -> to_path ( $ link [ 'i... | Gets the user shortcuts list |
10,513 | public function remove ( string $ id ) { if ( \ bbn \ str :: is_uid ( $ id ) ) { if ( $ id_menu = $ this -> get_id_menu ( $ id ) ) { if ( $ this -> pref -> delete_bit ( $ id ) ) { $ this -> delete_cache ( $ id_menu ) ; return true ; } } else if ( $ this -> pref -> delete ( $ id ) ) { $ this -> options -> delete_cache (... | Removes menu and deletes parent cache |
10,514 | public function add ( $ id_menu , array $ cfg = null ) : ? string { $ ids = [ ] ; if ( \ is_array ( $ id_menu ) ) { $ cfg = $ id_menu ; $ id_opt = $ this -> from_path ( 'menus' ) ; } if ( ! empty ( $ cfg ) ) { if ( \ bbn \ str :: is_uid ( $ id_menu ) ) { $ id = $ this -> pref -> add_bit ( $ id_menu , $ cfg ) ; } else {... | Add menu and delete the chache . |
10,515 | public function set ( string $ id , array $ cfg ) : bool { if ( \ bbn \ str :: is_uid ( $ id ) && ( $ id_menu = $ this -> get_id_menu ( $ id ) ) && $ this -> pref -> update_bit ( $ id , $ cfg ) ) { $ this -> delete_cache ( $ id_menu ) ; return true ; } return false ; } | Updates a menu item and deletes the menu cache |
10,516 | public function set_text ( string $ id , string $ text ) : bool { if ( \ bbn \ str :: is_uid ( $ id ) && $ this -> pref -> set_text ( $ id , $ text ) ) { $ this -> delete_cache ( $ id ) ; return true ; } return false ; } | Sets the menu s text and deletes its chache |
10,517 | public function delete_cache ( $ id_menu ) { $ this -> options -> delete_cache ( $ this -> from_path ( 'menus' ) , true ) ; return $ this -> cache_delete ( $ id_menu ) ; } | Clears the menu cache |
10,518 | public function get_default ( ) : ? string { if ( ( $ id_opt = $ this -> from_path ( 'default' ) ) && ( $ all = $ this -> pref -> get_all ( $ id_opt ) ) ) { $ id = false ; foreach ( $ all as $ a ) { if ( ! empty ( $ a [ 'id_user' ] ) ) { $ id = $ a [ 'id_alias' ] ; break ; } else if ( ! empty ( $ a [ 'id_group' ] ) ) {... | Gets the user s default menu |
10,519 | public function clone ( string $ id , string $ name ) : ? string { if ( \ bbn \ str :: is_uid ( $ id ) && ( $ id_menu = $ this -> add ( [ 'text' => $ name ] ) ) ) { if ( ( $ bits = $ this -> pref -> get_full_bits ( $ id ) ) && ! $ this -> _clone ( $ id_menu , $ bits ) ) { return null ; } return $ id_menu ; } return nul... | Clones a menu |
10,520 | public function copy ( string $ id_menu , string $ id_menu_to , array $ cfg ) : ? string { if ( \ bbn \ str :: is_uid ( $ id_menu ) && \ bbn \ str :: is_uid ( $ id_menu_to ) && ( $ bits = $ this -> pref -> get_full_bits ( $ id_menu ) ) && ( $ id = $ this -> add ( $ id_menu_to , $ cfg ) ) && $ this -> _clone ( $ id_menu... | Copies a menu into another one . |
10,521 | public function insert ( $ entity ) { $ values = $ this -> getInsertValues ( $ entity , $ this -> namingContention ) ; $ keyString = implode ( array_keys ( $ values ) , ', ' ) ; $ questionMarkString = count ( $ values ) === 0 ? '' : ( '?' . str_repeat ( ', ?' , count ( $ values ) - 1 ) ) ; $ sql = "INSERT INTO $this->t... | Insert an entity into the database . You can optionally provide a property name . If you do the inserted id will be assigned to that property . |
10,522 | public function update ( $ entity ) { if ( $ this -> idProperty === null ) { throw new ConfigurationException ( 'No idProperty set' ) ; } $ id = $ this -> idProperty -> getValue ( $ entity ) ; if ( $ id === null ) { throw new ConfigurationException ( 'Value of ' . $ this -> idProperty -> getName ( ) . ' is null' ) ; } ... | Update an existing entity in the database . |
10,523 | public function save ( $ entity ) { if ( $ this -> idProperty -> getValue ( $ entity ) === null ) { return $ this -> insert ( $ entity ) ; } else { return $ this -> update ( $ entity ) ; } } | Insert an entity into the database if it has no id yet . Otherwise update it by id . |
10,524 | public function get ( $ id ) { $ idName = ucfirst ( $ this -> idProperty -> getName ( ) ) ; return $ this -> __call ( "getBy$idName" , array ( $ id ) ) ; } | Get an entity by it s idProperty value . |
10,525 | public function delete ( $ id ) { $ idName = ucfirst ( $ this -> idProperty -> getName ( ) ) ; return $ this -> __call ( "deleteBy$idName" , array ( $ id ) ) ; } | Delete an entity by it s idProperty value . |
10,526 | private function addMethod ( $ method ) { $ tokens = $ this -> methodParser -> parse ( $ method ) ; $ query = $ this -> queryBuilder -> build ( $ tokens , $ this -> tableName , $ this -> namingContention , $ this -> entityClass ) ; if ( $ query -> getResultMode ( ) <= QueryBuilderResult :: RESULT_SELECT_MULTIPLE ) { $ ... | Parse a dsl method and add it to this repository . |
10,527 | private function addSelectionMethod ( QueryBuilderResult $ query , $ methodName ) { $ findMethod = function ( ) use ( $ query , $ methodName ) { $ sth = $ this -> pdo -> prepare ( $ query -> getSql ( ) ) ; $ sth -> setFetchMode ( \ PDO :: FETCH_CLASS , $ this -> entityClass -> getName ( ) ) ; try { $ sth -> execute ( f... | Add a method that can either result in an entity or an array of entities . |
10,528 | private function addIntResultMethod ( QueryBuilderResult $ query , $ methodName ) { $ intResultMethod = function ( ) use ( $ query ) { $ sth = $ this -> pdo -> prepare ( $ query -> getSql ( ) ) ; $ sth -> execute ( func_get_args ( ) ) ; return $ sth -> rowCount ( ) ; } ; $ this -> methods [ $ methodName ] = \ Closure :... | Add a new method that will result in an integer . |
10,529 | public function checkDatabase ( $ showAllData = true ) { switch ( $ this -> pdo -> getAttribute ( PDO :: ATTR_DRIVER_NAME ) ) { case 'mysql' : $ sth = $ this -> pdo -> prepare ( 'SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_NAME = ?' ) ; $ sth -> execute ( array ( $ this -> tableName ) ) ; $ columnNam... | This method will run some analysis on the correctness of your configuration . It will be exported to the screen . |
10,530 | protected function getPDO ( ) { if ( null === $ this -> pdo ) { $ this -> pdo = new \ PDO ( $ this -> dsn , $ this -> user , $ this -> password , $ this -> options ) ; } return $ this -> pdo ; } | Get PDO object . Cache the result |
10,531 | public function register ( Application $ app ) { $ app [ 'parser.example.finder' ] = new Example \ Finder ( ) ; $ this -> addCache ( $ app ) ; $ this -> addAssemblers ( $ app ) ; $ this -> addFilters ( $ app ) ; $ this -> addValidators ( $ app ) ; $ this -> addBuilder ( $ app ) ; $ this -> attachFiltersToManager ( $ ap... | Adds the services needed to build the descriptors . |
10,532 | public function attachFiltersToManager ( Filter $ filterManager , Application $ app ) { $ stripOnVisibility = new StripOnVisibility ( $ app [ 'descriptor.builder' ] ) ; $ filtersOnAllDescriptors = array ( new StripInternal ( $ app [ 'descriptor.builder' ] ) , new StripIgnore ( $ app [ 'descriptor.builder' ] ) ) ; forea... | Attaches filters to the manager . |
10,533 | protected function addCache ( Application $ app ) { $ app [ 'descriptor.cache' ] = $ app -> share ( function ( ) { $ cache = new Filesystem ( ) ; $ cache -> setOptions ( array ( 'namespace' => 'phpdoc-cache' , 'cache_dir' => sys_get_temp_dir ( ) , ) ) ; $ plugin = new SerializerPlugin ( ) ; if ( extension_loaded ( 'igb... | Adds the caching mechanism to the dependency injection container with key descriptor . cache . |
10,534 | protected function addBuilder ( Application $ app ) { if ( extension_loaded ( 'igbinary' ) ) { $ app [ 'descriptor.builder.serializer' ] = 'IgBinary' ; } else { $ app [ 'descriptor.builder.serializer' ] = 'PhpSerialize' ; } $ app [ 'descriptor.builder' ] = $ app -> share ( function ( $ container ) { $ builder = new Pro... | Adds the Building mechanism using the key descriptor . builder . |
10,535 | protected function addAssemblers ( Application $ app ) { $ app [ 'descriptor.builder.assembler.factory' ] = $ app -> share ( function ( ) { return new AssemblerFactory ( ) ; } ) ; $ provider = $ this ; $ app [ 'descriptor.builder.assembler.factory' ] = $ app -> share ( $ app -> extend ( 'descriptor.builder.assembler.fa... | Adds the assembler factory and attaches the basic assemblers with key descriptor . builder . assembler . factory . |
10,536 | protected function addValidators ( Application $ app ) { if ( ! isset ( $ app [ 'validator' ] ) ) { throw new Exception \ MissingDependencyException ( 'The validator manager is missing' ) ; } $ provider = $ this ; $ app [ 'validator' ] = $ app -> share ( $ app -> extend ( 'validator' , function ( $ validatorManager ) u... | Adds validators for the descriptors to the validator manager . |
10,537 | public function parseUrl ( $ url , array $ data ) { return ( empty ( $ data ) ) ? $ url : $ url . '?' . $ this -> parseData ( $ data ) ; } | Build URL with query string |
10,538 | public function getChainFor ( $ fqcn ) { if ( ! isset ( $ this -> chains [ $ fqcn ] ) ) { $ this -> chains [ $ fqcn ] = new FilterChain ( ) ; } return $ this -> chains [ $ fqcn ] ; } | Retrieves the filters for a class with a given FQCN . |
10,539 | protected function getRateLimit ( array $ headers ) { $ rateLimit = array ( 'limit' => '?' , 'reset' => '?' , ) ; foreach ( $ headers as $ header ) { $ header = trim ( $ header ) ; if ( false === strpos ( $ header , 'X-RateLimit-' ) ) { continue ; } list ( $ type , $ value ) = explode ( ':' , $ header , 2 ) ; switch ( ... | Extract ratelimit from response . |
10,540 | public function connect ( ) { if ( ! is_numeric ( $ this -> port ) ) { if ( substr ( $ this -> host , 0 , 3 ) == 'ssl' ) { $ this -> port = 5223 ; $ this -> log ( "Connecting with SSL" ) ; } else { $ this -> port = 5222 ; } } parent :: __construct ( $ this -> host . ':' . $ this -> port , $ this -> timeout ) ; $ this -... | Connects to the XMPP server |
10,541 | public function login ( ) { if ( ! $ this -> connected ) { $ this -> reconnect ( ) ; } $ this -> jid = $ this -> uname . '@' . substr ( $ this -> host , strpos ( $ this -> host , '//' ) + 2 ) ; if ( $ this -> pass ) { $ this -> write ( "<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>" . base64_encode ... | Login to the XMPP server as a user and set their precence to avaiable |
10,542 | public function sendPresence ( \ sb \ XMPP \ Presence $ presence ) { $ presence -> setFrom ( $ this -> jid ) ; return $ this -> write ( $ presence ) ; } | Converts a presense request instance to XML and sends it . It sets the from to the bots jid for you |
10,543 | public function setStatus ( $ status = null ) { $ presence = new \ sb \ XMPP \ Presence ( ) ; $ presence -> setStatus ( is_string ( $ status ) ? $ status : $ this -> status ) ; $ this -> sendPresence ( $ presence ) ; } | Sets status message |
10,544 | public function sendSimpleMessage ( $ to , $ body ) { $ message = new \ sb \ XMPP \ Message ( ) ; $ message -> setTo ( $ to ) ; $ message -> setBody ( $ body ) ; $ this -> sendMessage ( $ message ) ; } | Sends simple string based text message |
10,545 | public function sendAcceptSubscriptionRequest ( $ to ) { $ presence = new \ sb \ XMPP \ Presence ( ) ; $ presence -> setType ( 'subscribed' ) ; $ presence -> setTo ( $ to ) ; return $ this -> sendPresence ( $ presence ) ; } | Send a presence message accepting subscription request to a jid |
10,546 | public function sendSubscriptionRequest ( $ to ) { $ presence = new \ sb \ XMPP \ Presence ( ) ; $ presence -> setTo ( $ to ) ; $ presence -> setType ( 'subscribe' ) ; $ presence -> setFrom ( $ this -> jid ) ; return $ this -> sendPresence ( $ presence ) ; } | Sends a subscription request to a jid |
10,547 | public function sleep ( $ secs ) { $ str = 'Going to sleep for ' . $ secs . 'secs' ; $ this -> log ( 'NOTICE: ' . $ str ) ; $ this -> setStatus ( $ str ) ; sleep ( $ secs ) ; $ this -> setStatus ( $ this -> status ? $ this -> status : 'awake' ) ; } | Puts the bot to sleep for a while |
10,548 | public function composingStart ( $ to ) { $ message = new \ sb \ XMPP \ Message ( ) ; $ message -> setTo ( $ to ) ; $ message -> setFrom ( $ this -> jid ) ; $ message -> setType ( 'chat' ) ; $ node = $ message -> createElement ( 'composing' ) ; $ attr = $ message -> createAttribute ( 'xmlns' ) ; $ node -> appendChild (... | Send an indication that the bot is composing text . |
10,549 | final public function read ( $ byte_count = null ) { $ buffer = '' ; $ read = array ( $ this -> socket ) ; $ updated = @ stream_select ( $ read , $ write , $ except , 1 ) ; if ( $ updated > 0 ) { $ data = fread ( $ this -> socket , 4096 ) ; if ( $ data ) { $ buffer = $ data ; } } if ( ! empty ( $ buffer ) ) { $ this ->... | Reads from the socket should be protected but can t because this is inherited as public |
10,550 | final public function listen ( ) { $ this -> log ( "Listening..." ) ; $ x = 1 ; while ( $ x ) { $ x ++ ; $ xml = $ this -> read ( 1024 ) ; if ( ! empty ( $ xml ) ) { if ( $ this -> onRead ( $ xml ) === false ) { return false ; } } if ( substr ( $ xml , 0 , 8 ) == '<message' ) { $ message = new \ sb \ XMPP \ Message ( $... | Listens for incoming chat on the socket |
10,551 | final public function write ( $ xml ) { if ( $ xml instanceof \ SimpleXMLElement ) { $ xml = $ xml -> asXML ( ) ; } elseif ( $ xml instanceof \ DOMDocument ) { $ xml = $ xml -> saveXML ( ) ; } $ this -> log ( "SENT: " . $ xml ) ; return parent :: write ( $ xml ) ; } | Writes XML to the socket client |
10,552 | final public function close ( ) { $ this -> onCloseConnection ( ) ; if ( $ this -> socket ) { $ this -> write ( "</stream:stream>" ) ; parent :: close ( ) ; $ this -> connected = false ; } } | Ends the stream and closes the connection |
10,553 | public function indexTree ( $ id = null ) { $ this -> authorize ( 'readList' , Content :: class ) ; $ input = $ this -> validator -> validate ( 'tree' ) ; $ params = $ this -> processor -> process ( $ input ) -> getProcessedFields ( ) ; $ this -> getSerializer ( ) -> parseIncludes ( 'children' ) ; if ( $ id ) { $ conte... | Display a listing of the resource as nested tree . |
10,554 | protected function buildSyncData ( array $ input ) { $ syncData = [ ] ; foreach ( $ input [ 'data' ] as $ item ) { $ syncData [ $ item [ 'id' ] ] = [ 'weight' => isset ( $ item [ 'weight' ] ) ? $ item [ 'weight' ] : 0 ] ; } return $ syncData ; } | It builds syncData |
10,555 | public function getRemainingLifetime ( $ id , $ attributes = array ( ) ) { if ( count ( $ found = $ this -> search ( $ id , $ attributes ) ) > 0 ) { $ identifier = $ found [ 0 ] [ 2 ] ; return $ this -> calcLifetime ( $ identifier ) ; } return 0 ; } | Returns the time in seconds which remains for a cache object before it gets outdated . In case the cache object is already outdated or does not exists this method returns 0 . |
10,556 | public function generateIdentifier ( $ id , $ attributes = null ) { $ identifier = strtolower ( $ this -> backendName ) . $ this -> properties [ 'location' ] . $ id . ( ( $ attributes !== null && ! empty ( $ attributes ) ) ? md5 ( serialize ( $ attributes ) ) : '' ) ; return urlencode ( $ identifier ) ; } | Generates the storage internal identifier from ID and attributes . |
10,557 | public function purge ( $ limit = null ) { $ this -> fetchSearchRegistry ( true ) ; $ purgedIds = array ( ) ; $ ttl = $ this -> properties [ 'options' ] -> ttl ; foreach ( $ this -> searchRegistry [ $ this -> properties [ 'location' ] ] as $ id => $ identifiers ) { $ deleted = false ; foreach ( $ identifiers as $ ident... | Purge outdated data from the storage . |
10,558 | public function reset ( ) { $ this -> backend -> reset ( ) ; $ this -> registry = array ( ) ; $ this -> searchRegistry = array ( $ this -> properties [ 'location' ] => null ) ; $ this -> storeSearchRegistry ( ) ; } | Reset the complete storage . |
10,559 | protected function registerIdentifier ( $ id = null , $ attributes = array ( ) , $ identifier = null ) { $ identifier = ( $ identifier !== null ) ? $ identifier : $ this -> generateIdentifier ( $ id , $ attributes ) ; $ location = $ this -> properties [ 'location' ] ; $ this -> fetchSearchRegistry ( ) ; if ( ! isset ( ... | Registers an identifier to facilitate searching . |
10,560 | protected function unRegisterIdentifier ( $ id = null , $ attributes = array ( ) , $ identifier = null , $ delayStore = false ) { $ identifier = ( $ identifier !== null ) ? $ identifier : $ this -> generateIdentifier ( $ id , $ attributes ) ; $ location = $ this -> properties [ 'location' ] ; $ this -> fetchSearchRegis... | Un - registers a previously registered identifier . |
10,561 | protected function fetchSearchRegistry ( $ requireFresh = false ) { $ location = $ this -> properties [ 'location' ] ; if ( ! is_array ( $ this -> searchRegistry ) ) { $ this -> searchRegistry = array ( ) ; } if ( ! isset ( $ this -> searchRegistry [ $ location ] ) || ! is_array ( $ this -> searchRegistry [ $ location ... | Fetches the search registry from the backend or creates it if empty . |
10,562 | protected function storeSearchRegistry ( ) { $ location = $ this -> properties [ 'location' ] ; $ this -> backend -> store ( $ this -> registryName . '_' . urlencode ( $ location ) , $ this -> searchRegistry [ $ location ] ) ; $ this -> searchRegistry [ $ location ] = null ; $ this -> fetchSearchRegistry ( true ) ; } | Stores the search registry in the backend . |
10,563 | public function apiStore ( ) { DB :: beginTransaction ( ) ; try { $ record = $ this -> __apiStore ( ) ; } catch ( \ Exception $ e ) { DB :: rollback ( ) ; return HCLog :: error ( 'CORE-0002' . $ e -> getCode ( ) , $ e -> getMessage ( ) ) ; } DB :: commit ( ) ; return response ( $ record ) ; } | Function which will store new record |
10,564 | public function apiUpdate ( string $ id ) { DB :: beginTransaction ( ) ; try { $ record = $ this -> __apiUpdate ( $ id ) ; } catch ( \ Exception $ e ) { DB :: rollback ( ) ; return HCLog :: error ( 'CORE-0003' . $ e -> getCode ( ) , $ e -> getMessage ( ) ) ; } DB :: commit ( ) ; return $ record ; } | Function which will update record |
10,565 | public function apiUpdateStrict ( string $ id ) { DB :: beginTransaction ( ) ; try { $ record = $ this -> __apiUpdateStrict ( $ id ) ; } catch ( \ Exception $ e ) { DB :: rollback ( ) ; return HCLog :: error ( 'CORE-0003' . $ e -> getCode ( ) , $ e -> getMessage ( ) ) ; } DB :: commit ( ) ; return $ record ; } | Function which will update specific values of the record |
10,566 | private function initializeDelete ( string $ id = null , bool $ soft ) { if ( $ id ) $ list = [ $ id ] ; else $ list = request ( ) -> input ( 'list' ) ; if ( sizeOf ( $ list ) <= 0 ) return HCLog :: info ( 'CORE-0004' , trans ( 'HCTranslations::core.nothing_to_delete' ) ) ; DB :: beginTransaction ( ) ; try { if ( $ sof... | Function which will actually call deletion function |
10,567 | public function apiRestore ( ) { $ toRestore = request ( ) -> input ( 'list' ) ; if ( sizeOf ( $ toRestore ) <= 0 ) return HCLog :: info ( 'CORE-0006' , trans ( 'HCTranslations::core.nothing_to_restore' ) ) ; $ response = $ this -> __apiRestore ( $ toRestore ) ; if ( isset ( $ response ) ) return $ response ; return [ ... | Recovers items from database by given id s Just need to set wanted Model name with list parameter |
10,568 | public function apiMerge ( ) { DB :: beginTransaction ( ) ; try { $ record = $ this -> __apiMerge ( ) ; } catch ( \ Exception $ e ) { DB :: rollback ( ) ; return HCLog :: error ( 'CORE-0007' . $ e -> getCode ( ) , $ e -> getMessage ( ) ) ; } DB :: commit ( ) ; return $ record ; } | Function will can be used to merge multiple records into one |
10,569 | protected function downloadExchangeRatesTable ( ) { try { $ this -> table [ $ this -> baseCurrency ] = 1 ; $ xml = simplexml_load_file ( $ this -> url , 'SimpleXMLElement' , LIBXML_NOWARNING ) ; if ( $ xml instanceof \ SimpleXMLElement ) { $ data = $ xml -> xpath ( '//gesmes:Envelope/*[3]/*' ) ; foreach ( $ data [ 0 ] ... | Downloads exchange rates table from ECB |
10,570 | protected function updateCurrencyRates ( Currency $ currency ) { $ baseExchangeRate = $ this -> table [ $ currency -> getCode ( ) ] ; foreach ( $ this -> table as $ currencySymbol => $ exchangeRate ) { $ rate = $ this -> calculateExchangeRate ( $ baseExchangeRate , $ currencySymbol ) ; $ this -> addUpdateExchangeRate (... | Updates managed currency with exchange rates |
10,571 | protected function point ( ) { if ( ! $ this -> point -> isLoaded ( ) ) { $ url = str_replace ( "{point}" , $ this -> point -> getLat ( ) . "," . $ this -> point -> getLon ( ) , self :: POINT ) ; $ res = $ this -> load ( $ url , Point :: TTL ) ; $ this -> point -> setProperties ( $ res ) ; } return $ this -> point ; } | ensure point has data loaded |
10,572 | public function getGroup ( ) { $ request = $ this -> container -> get ( 'request' ) ; $ groupInfo = $ request -> getSession ( ) -> get ( CustomerGroup :: getModuleCode ( ) ) ; return $ groupInfo ; } | Get CustomerGroup of the current customer |
10,573 | public function checkGroup ( $ groupCode ) { $ securityContext = $ this -> container -> get ( 'thelia.securityContext' ) ; return $ securityContext -> hasCustomerUser ( ) && $ this -> getGroupCode ( ) === $ groupCode ; } | Check if the current customer is in the asked group |
10,574 | public function checkCustomerHasGroup ( Customer $ customer , $ groupCode ) { $ group = CustomerCustomerGroupQuery :: create ( ) -> filterByCustomer ( $ customer ) -> useCustomerGroupQuery ( ) -> filterByCode ( $ groupCode ) -> endUse ( ) -> findOne ( ) ; return $ group !== null ; } | Check that a customer belongs to a group . |
10,575 | protected function init ( ) { $ this -> container -> set ( 'logger' , function ( $ c ) { $ configuration = $ c -> get ( 'configuration' ) ; $ logger = new Logger ( $ configuration [ 'logger' ] ) ; return $ logger ; } ) ; $ this -> container -> set ( MiddlewareFactory :: class , function ( $ c ) { return new MiddlewareF... | Initializes application s components |
10,576 | public function registerErrorHandler ( ) { $ whoops = new \ Whoops \ Run ( ) ; $ configuration = $ this -> getConfiguration ( ) ; if ( isset ( $ configuration [ 'debug' ] ) && $ configuration [ 'debug' ] ) { $ whoops -> pushHandler ( new \ Whoops \ Handler \ PrettyPageHandler ( ) ) ; } else { $ whoops -> pushHandler ( ... | Registers error handler for this application |
10,577 | public function run ( ) { $ request = $ this -> request ; $ response = $ this -> response ; $ config = $ this -> configuration ; $ httpMethod = $ request -> getMethod ( ) ; $ pathInfo = $ request -> getUri ( ) -> getPath ( ) ; if ( empty ( $ pathInfo ) ) { $ pathInfo = '/' ; } $ routeObject = $ this -> router -> resolv... | Runs application to handle request . |
10,578 | protected function emitResponse ( ResponseInterface $ response ) { $ this -> logger -> flush ( ) ; ( new \ Zend \ HttpHandlerRunner \ Emitter \ SapiEmitter ( ) ) -> emit ( $ response ) ; } | Emits response to client |
10,579 | protected function convertCallbackToClosure ( $ callback , $ namespace ) { if ( $ callback instanceof Closure || is_callable ( $ callback ) ) { return $ callback ; } elseif ( is_string ( $ callback ) ) { $ namespace = rtrim ( $ namespace , '\\' ) . '\\' ; $ arrCallback = explode ( '::' , $ callback ) ; $ isStaticCall =... | Converts callback to Closure . |
10,580 | public function arretsToHide ( $ newsletter_id = null ) { $ campagnes = $ this -> campagne -> getAll ( $ newsletter_id ) -> where ( 'status' , 'brouillon' ) ; return $ campagnes -> flatMap ( function ( $ campagne ) { return $ campagne -> content ; } ) -> map ( function ( $ content , $ key ) { if ( $ content -> arret_id... | Interaction with site controllers List of arrets in non sent campagne to hide on frontend |
10,581 | public function siteCampagnes ( $ site_id ) { if ( config ( 'newsletter.multi' ) ) { $ newsletters = $ this -> newsletter -> getSite ( $ site_id ) ; return $ newsletters -> map ( function ( $ newsletter , $ key ) { return $ newsletter -> campagnes ; } ) -> flatten ( 1 ) ; } return null ; } | All campagnes for site |
10,582 | public function html ( $ id ) { libxml_use_internal_errors ( true ) ; $ htmldoc = new InlineStyle ( file_get_contents ( url ( 'campagne/' . $ id ) ) ) ; $ htmldoc -> applyStylesheet ( $ htmldoc -> extractStylesheets ( ) ) ; $ html = $ htmldoc -> getHTML ( ) ; $ html = preg_replace ( '#<script(.*?)>(.*?)</script>#is' , ... | Put styles inline for campagne Used when sending cammpagne or test |
10,583 | public function save_config ( array $ cfg , $ description , $ class = 'grid' ) { if ( isset ( $ cfg [ 'elements' ] ) ) { $ copy = $ cfg ; unset ( $ copy [ 'elements' ] ) ; $ obj_param = [ 'id_project' => 1 , 'class' => $ class , 'description' => $ description , 'configuration' => json_encode ( $ copy ) ] ; if ( isset (... | Saves the given configuration in the database and returns the new ID |
10,584 | public function getSubscriptionById ( $ subscriptionId ) { $ subscriptions = $ this -> getSubscriptions ( null , null , null , $ subscriptionId ) -> getResponse ( ) -> getSubscriptions ( ) ; return count ( $ subscriptions ) ? reset ( $ subscriptions ) : null ; } | Get one subscription by using the Monsum subscription ID . |
10,585 | public function getSubscriptions ( $ customerId = null , $ externalCustomerId = null , $ subscriptionExternalId = null , $ subscriptionId = null ) { $ requestData = new Get \ RequestData ( ) ; $ requestData -> setCustomerId ( $ customerId ) ; $ requestData -> setExternalCustomerId ( $ externalCustomerId ) ; $ requestDa... | Get the subscriptions . |
10,586 | public function getAllSubscriptions ( ) { $ limit = RequestInterface :: MAX_LIST_LIMIT ; $ offset = 0 ; $ subscriptions = [ [ ] ] ; while ( true ) { $ subscriptionBatch = $ this -> getSubscriptionsResponse ( $ offset ) ; $ subscriptions [ ] = $ subscriptionBatch ; $ offset += $ limit ; if ( \ count ( $ subscriptionBatc... | Get all subscriptions . |
10,587 | public function createSubscription ( Create \ RequestData $ requestData ) { $ request = new Create \ Request ( $ requestData ) ; return $ this -> sendRequest ( $ request , Create \ ApiResponse :: class ) ; } | Create a subscription . |
10,588 | public function updateSubscription ( $ subscriptionId , $ nextEvent = null , $ subscriptionExternalId = null , $ status = null , array $ xAttributes = [ ] , array $ features = [ ] ) { $ requestData = new Update \ RequestData ( $ subscriptionId ) ; $ requestData -> setSubscriptionId ( $ subscriptionId ) ; $ requestData ... | Update a subscription . |
10,589 | public function changeSubscriptionArticle ( ChangeArticle \ RequestData $ requestData ) { $ request = new ChangeArticle \ Request ( $ requestData ) ; return $ this -> sendRequest ( $ request , ChangeArticle \ ApiResponse :: class ) ; } | Change article of a subscription . |
10,590 | public function setSubscriptionAddon ( SetAddon \ RequestData $ requestData ) { $ request = new SetAddon \ Request ( $ requestData ) ; return $ this -> sendRequest ( $ request , SetAddon \ ApiResponse :: class ) ; } | Set the addon for a subscription . |
10,591 | public function setSubscriptionUsageData ( SetUsageData \ RequestData $ requestData ) { $ request = new SetUsageData \ Request ( $ requestData ) ; return $ this -> sendRequest ( $ request , SetUsageData \ ApiResponse :: class ) ; } | Set the usage data of a subscription . |
10,592 | public function getUpcomingAmount ( GetUpcomingAmount \ RequestData $ requestData = null ) { if ( $ requestData === null ) { $ requestData = new GetUpcomingAmount \ RequestData ( ) ; } $ request = new GetUpcomingAmount \ Request ( $ requestData ) ; return $ this -> sendRequest ( $ request , GetUpcomingAmount \ ApiRespo... | Get the upcoming amount . |
10,593 | public function postponeSubscription ( $ subscriptionId , $ month ) { $ requestData = new Postpone \ RequestData ( $ subscriptionId , $ month ) ; $ request = new Postpone \ Request ( $ requestData ) ; return $ this -> sendRequest ( $ request , Postpone \ ApiResponse :: class ) ; } | Postpone a subscription shipping . |
10,594 | public function renewSubscription ( $ subscriptionId ) { $ requestData = new Renew \ RequestData ( $ subscriptionId ) ; $ request = new Renew \ Request ( $ requestData ) ; return $ this -> sendRequest ( $ request , Renew \ ApiResponse :: class ) ; } | Renew a subscription . |
10,595 | public function createSecureLink ( $ subscriptionId ) { $ requestData = new CreateSecureLink \ RequestData ( $ subscriptionId ) ; $ request = new CreateSecureLink \ Request ( $ requestData ) ; return $ this -> sendRequest ( $ request , CreateSecureLink \ ApiResponse :: class ) ; } | Create a secure link for a subscription . |
10,596 | public function cancelSubscription ( $ subscriptionId , \ DateTime $ cancellationDate = null , $ cancellationNote = null ) { $ requestData = new Cancel \ RequestData ( $ subscriptionId ) ; $ requestData -> setCancellationDate ( $ cancellationDate ) ; $ requestData -> setCancellationNote ( $ cancellationNote ) ; $ reque... | Cancel a subscription . |
10,597 | public function reactivateSubscription ( $ subscriptionId ) { $ requestData = new Reactivate \ RequestData ( $ subscriptionId ) ; $ request = new Reactivate \ Request ( $ requestData ) ; return $ this -> sendRequest ( $ request , Reactivate \ ApiResponse :: class ) ; } | Reactivate a subscription . |
10,598 | public static function stripBase ( $ path , $ base = null ) { if ( $ base === null ) $ base = getcwd ( ) ; if ( substr ( $ path , 0 , strlen ( $ base ) ) === $ base ) return ltrim ( substr ( $ path , strlen ( $ base ) + 1 ) , "/" ) ; else throw new PathException ( "\"$path\" does not contain base path \"$base\"" ) ; } | Strips a base from a file or directory path . If no base is supplied the working directory is used . |
10,599 | public static function rootPath ( $ directory ) { $ num = count ( explode ( "/" , $ directory ) ) ; $ path = "" ; for ( $ i = 0 ; $ i < $ num ; $ i ++ ) $ path = self :: join ( ".." , $ path ) ; return $ path ; } | Builds a path referring to the root directory from a relative path . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.