extend() public static method

Extend class namespace.
public static extend ( string | array $target, array $source ) : unknown_type
$target string | array
$source array
return unknown_type
Ejemplo n.º 1
0
 public function testExtend()
 {
     $newMethods = array('newMethod1' => array($this, 'callback1'), 'newMethod2' => array($this, 'callback2'));
     phpQuery::extend('phpQueryObject', $newMethods);
     $doc = phpQuery::newDocumentXML("<div/>");
     $this->assertTrue($doc->newMethod1() == $doc, '$doc->newMethod1 == $doc');
     $this->assertTrue($doc->newMethod2() == "callback2", '$doc->newMethod1 == "callback2"');
 }
Ejemplo n.º 2
0
<?php

require_once '../phpQuery/phpQuery.php';
phpQuery::$debug = true;
phpQuery::extend('WebBrowser');
phpQuery::$ajaxAllowedHosts[] = 'gmail.com';
phpQuery::$ajaxAllowedHosts[] = 'google.com';
phpQuery::$ajaxAllowedHosts[] = 'www.google.com';
phpQuery::$ajaxAllowedHosts[] = 'www.google.pl';
phpQuery::$ajaxAllowedHosts[] = 'mail.google.com';
// Google search results
if (0) {
    phpQuery::$plugins->browserGet('http://google.com/', 'success1');
    /**
     *
     * @param $pq phpQueryObject
     * @return unknown_type
     */
    function success1($pq)
    {
        print 'success1 callback';
        $pq->WebBrowser('success2')->find('input[name=q]')->val('phpQuery')->parents('form')->submit();
    }
    /**
     *
     * @param $html phpQueryObject
     * @return unknown_type
     */
    function success2($pq)
    {
        print 'success2 callback';