实例化一个DdvPage对象
@param \Illuminate\Pagination\LengthAwarePaginator|\Illuminate\Database\Eloquent\Builder|false $obj   [数据库对象模型]
@return \DdvPhp\DdvPage $page [分页对象]
199895
public static function create($obj = false){
    $className =  get_called_class();
    $page = new $className(false);
    call_user_func_array(array($page, '__construct'), func_get_args());
    return $page;
  }
630069
public function push($obj)
    {
        if (!$obj) {
            return;
        }

        $cls           = get_called_class();
        $escape        = Driver::$escape_char;
        $value         = array_key_exists(self::getPK(), $this->_data) ? $this->_data[self::getPK()] : null;
        $other_cls     = get_class($obj);
        $other_pk      = $other_cls::getPK();
        $other_value   = $obj->get($other_pk);
        $table         = Model::getTableName($other_cls);
        $foreign       = self::hasManyForeignKey(Inflections::pluralize(strtolower($other_cls)));

        // if the current object exists ...
        if (!is_null($value)) {
            $obj->set(strtolower($foreign), $value);

            // if the pushed object is still not saved
            if (is_null($other_value)) {
                if (!$obj->save()) {
                    return false;
                }
                $other_value = $obj->get($other_pk);
            }

            $foreign    = self::$_mapping[$other_cls][$foreign];
            $other_pk   = self::$_mapping[$other_cls][$other_pk];
            $sql        = "update $escape$table$escape set $escape$foreign$escape=$value where $escape$other_pk$escape=$other_value";
            $stmt       = self::query($sql);
            $rst        = $stmt->rowCount()==1;
            self::closeCursor($stmt);
            return $rst;
        }

        // if current object does not exists ...
        if (is_null($value)) {
            $this->_pushLater($obj);
        }
    }
1103816
public function paginate($perPage = 25, $currentPage = null, array $options = [])
    {
        $currentPage = $this->getPageFromInput($currentPage, $options);
        $offset      = ($currentPage - 1) * $perPage;
        $total       = $this->count();
        $entries     = $this->get()->slice($offset, $perPage)->all();

        return new LengthAwarePaginator($entries, $total, $perPage, $currentPage, $options);
    }
150020
public function getByUrl(?string $url, $locale): ?Page
	{
		/* @var $orm Orm */
		$orm = $this->getRepository()->getModel();
		if ($locale instanceof Locale) {
			$eLocale = $locale;
		} else {
			$eLocale = $orm->locales->getByLocale($locale);
		}

		$urls = $this->getPageList();
		if (isset($urls[$url])) {
			$builder = $this->builder()
				->andWhere('[id] = %i', $urls[$url])
				->andWhere('[localeId] = %i', $eLocale->id);
			return $this->toEntity($builder);
		}
		return null;
	}
198227
public function Delete($obj)
	{
		$objectclass = get_class($obj);

		if (!$obj->OnBeforeDelete())
		{
			$this->Observe("Delete was cancelled because OnBeforeDelete did not return true");
			return 0;
		}

		$fms = $this->GetFieldMaps($objectclass);

		$pk = $obj->GetPrimaryKeyName();
		$id = $obj->$pk;
		$table = $fms[$pk]->TableName;
		$pkcol = $fms[$pk]->ColumnName;

		$sql = "delete from `$table` where `$pkcol` = '" . $this->Escape($id) . "'";
		$returnval = $this->DataAdapter->Execute($sql);

		// remove from cache
		$this->DeleteCache($objectclass,$id);

		$obj->OnDelete(); // fire OnDelete event

		return $returnval;

	}
273089
public function paginateRaw($perPage = null, $pageName = 'page', $page = null)
    {
        $engine = $this->engine();

        $page = $page ?: Paginator::resolveCurrentPage($pageName);

        $perPage = $perPage ?: $this->model->getPerPage();

        $results = $engine->paginate($this, $perPage, $page);

        $paginator = (new LengthAwarePaginator($results, $engine->getTotalCount($results), $perPage, $page, [
            'path' => Paginator::resolveCurrentPath(),
            'pageName' => $pageName,
        ]));

        return $paginator->appends('query', $this->query);
    }
61258
public static function sprint_r($obj)
    {
        ob_start();
        print_r($obj);
        $str = ob_get_contents();
        ob_end_clean();

        $str = preg_replace("/\s+\\(\s+/", " ( ", $str);
        $str = preg_replace("/\n\s+/", ", ", $str);
        $str = preg_replace("/\n\s*\\)/", " )", $str);
        return $str;
    }
1214829
public function load($obj, $cacheupd = false) {
		if (DEBUG_MODE) {
			BLog::addToLog('[Users.Session]: Load()');
		}

		$enddate = new \DateTime($obj['end']);
		$nowdate = new \DateTime();
		$lacdate = new \DateTime($obj['lastaction']);
		if (DEBUG_MODE) {
			BLog::addToLog('[Users.Session]: Load() enddate=' . $enddate->format('Y-m-d H:i:s'));
			BLog::addToLog('[Users.Session]: Load() nowdate=' . $nowdate->format('Y-m-d H:i:s'));
			BLog::addToLog('[Users.Session]: Load() lacdate=' . $lacdate->format('Y-m-d H:i:s'));
		}
		if (!is_string($obj['sessionid'])) {
			if (DEBUG_MODE) {
				BLog::addToLog('[Users.Session]: Load() sessionid is not a string!', LL_ERROR);
			}
			$this->sessionid = '';
			$this->close();
			return false;
		}
		if ($enddate < $nowdate) {
			if (DEBUG_MODE) {
				BLog::addToLog('[Users.Session]: Load() $enddate<$nowdate. Closing session.', LL_ERROR);
			}
			$this->sessionid = $obj['sessionid'];
			$this->close();
			return false;
		}
		if (($nowdate->getTimestamp() - $lacdate->getTimestamp()) > $obj['updatestep']) {
			if (!$db = BFactory::getDBO()) {
				return false;
			}
			$qr = 'update sessions set 
			     `end`=DATE_ADD(now(),INTERVAL ' . $obj['interval'] . ' SECOND),
			     lastaction=NOW()
			     WHERE sessionid=' . $db->escapeString($obj['sessionid']);
			$q = $db->Query($qr);
			if (empty($q)) {
				return false;
			}

			$qr = 'update users set last_action=NOW() where id=' . $obj['userid'];
			$q = $db->Query($qr);
			$busers = BUsers::getInstance();
			$me = $busers->itemGet($obj['userid']);
			if (!empty($me)) {
				$me->updatecache();
			}
			$lacdate = $nowdate;
			$enddate->add(new \DateInterval('PT' . $obj['interval'] . 'S'));
			$cacheupd = true;
		}
		$this->sessionid = $obj['sessionid'];
		$this->ipv4 = $obj['ipv4'];
		$this->start = new \DateTime($obj['start']);
		$this->end = $enddate;
		$this->lastaction = $lacdate;//->format("Y-m-d H:i:s");
		$this->userid = $obj['userid'];
		$this->data = unserialize($obj['data']);
		$this->updatestep = $obj['updatestep'];
		$this->interval = $obj['interval'];
		if (CACHE_TYPE && $cacheupd) {
			$obj['end'] = $this->end->format("Y-m-d H:i:s");;
			$obj['lastaction'] = $this->lastaction->format("Y-m-d H:i:s");;
			$bCache = BFactory::getCache();
			$bCache->set('session:' . $obj['sessionid'], $obj, 600);
		}
		return true;
	}
897924
public static function ddp($obj = NULL)
	{
		try
		{
			$json_str = json_encode($obj, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
			echo $json_str;
			die();
		}
		catch(SangriaException $e)
		{
			/**
			 * Default to dd if there is an exception while encoding to JSON
			 */
			var_dump($obj);
			die();	
		}
	}
263587
public function compareTo($obj) {
		
		if(!($obj instanceof static)){
			throw new \InvalidArgumentException('$obj is not a comparable instance');
		}
		
		$coll = new \Collator('');
		
		return $coll->compare($this->_Value, $obj->_Value);
		
	}
1324357
public function renderBeforeSuite($obj)
    {
        $print = array();
        foreach ($this->rendererList as $name => $renderer) {
            $print[$name] = $renderer->renderBeforeSuite($obj);
        }

        return $print;
    }
142791
public function getPagination()
    {
        $factory = new PaginationFactory(\Request::getInstance());
        if (method_exists($this, 'createPaginationObject')) {
            $pagination = $this->createPaginationObject();
            $pagination = $factory->deliverPaginationObject($this, $pagination);
        } else {
            $pagination = $factory->createPaginationObject($this);
        }
        return $pagination;
    }
442938
public function getPage($pageNumber)
    {
        $response = $this->makeQuery($pageNumber);
        $className = $this->typeClass->objectClass;
        $objects = array();
        if (!isset($response->data) || !$response->data)
            return array();
        foreach ($response->data as $object) {
            $objects[] = new $className($this->api, $this->typeClass, $object);
        }

        return $objects;
    }
44511
public function getPage($url)
    {
        $pages = $this->getPages();
        $url = $this->normalizeUrl($url);

        if (!isset($pages[$url])) {
            return null;
        }


        $record = $pages[$url];

        foreach ($this->getEntities() as $entity) {
            if (strpos($record['filepath'], $entity->getPath()) !== false) {
                $page =  Injector::inst()->create(
                    $record['type'],
                    $entity,
                    $record['basename'],
                    $record['filepath']
                );

                return $page;
            }
        }
    }
586316
private function hasIterator($obj) {
        $hasIterator = false;
        foreach ($obj as $key => $dummy) {
            $hasIterator = true;
            break;
        }
        return $hasIterator;
    }
649800
public static function getView( PrintaitorViewObj $printViewObj ) { 
        $data = $printViewObj->dataToView;
        $printer_id = $printViewObj->printerId;
        $templateName = $printViewObj->viewName;
        if (empty($printer_id)) {
            return -1;
        }

        
        $pluginPath = App::path('Lib', 'Printers');


        $driverName = $printViewObj->printer['Printer']['driver'];
        $driverModelName = $printViewObj->printer['Printer']['driver_model'];

        App::build(array('View' => array( $pluginPath[0] . '/DriverView')));

        $viewName = $driverName."Printer/$templateName";
        $View = new View();
        $View->set($data);
   
        $helperName = $driverModelName . $driverName.'Helper'    ;
        App::uses($helperName, 'Printers.Lib/DriverView/Helper');

        if (!class_exists($helperName)) {
            throw new MissingHelperException(array(
                'class' => $helperName,
                'plugin' => substr('Printers', 0, -1)
            ));
        }

        $View->PE = new $helperName($View);
        
        $View->printaitorObj = $printViewObj;
        $view = null;
        try {
            $view = $View->render( $viewName, false );
        } catch (Exception $e) {
            CakeLog::write('debug','No existe la vista de Plugin Printer para '.$e->getMessage() );
        }
        return $view;
        
    }
216010
public function renderBeforeScenario($obj)
    {
        //scenario head
        $print = '
            <div class="scenario">
                <ul class="tags">';
        foreach ($obj->getCurrentScenario()->getTags() as $tag) {
            $print .= '
                    <li>@'.$tag.'</li>';
        }
        $print .= '
                </ul>';

        $print .= '
                <h3>
                    <span class="keyword">'.$obj->getCurrentScenario()->getId().' Scenario: </span>
                    <span class="title">'.$obj->getCurrentScenario()->getName().'</span>
                </h3>
                <ol>';

        //TODO path is missing

        return $print;
    }