本文整理汇总了PHP中ArrayIterator::offsetSet方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayIterator::offsetSet方法的具体用法?PHP ArrayIterator::offsetSet怎么用?PHP ArrayIterator::offsetSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayIterator
的用法示例。
在下文中一共展示了ArrayIterator::offsetSet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ProcceedToPayment
public function ProcceedToPayment()
{
include_once "models/FlightModel.php";
$flightId = Request::RequestParams("flightid");
$category = Request::RequestParams("ticketcategory");
$children = Request::RequestParams("children");
$adults = Request::RequestParams("adults");
$typeticket = Request::RequestParams("typeticket");
//set the booking details
$booking = new BookInfo();
$booking->adult_no = isset($adults) ? $adults : 0;
$booking->children_no = isset($children) ? $children : 0;
$booking->flight_id = $flightId;
$booking->ticket_cat = $category;
$booking->ticket_type = $typeticket;
$flightModel = new FlightModel();
$this->viewModel->flightDbModel = $flightModel;
$this->viewModel->flight = $flightModel->GetFlightById($flightId);
if ($booking->validated()) {
if ($this->viewModel->flight != NULL) {
$booking->ticket_adult_price = $this->viewModel->flight->ticketPrice;
}
} else {
//else still required more informations
$attr = new ArrayIterator();
$attr->offsetSet("class", "warning");
$attr->offsetSet("style", "border:1px solid #000;");
ContextManager::ValidationFor("warning", $booking->getError());
}
$this->ViewBag("Title", "Booking");
$this->ViewBag("Controller", "Booking");
$this->ViewBag("Page", "Flight");
Session::set("BOOKINFO", $booking);
return $this->View($this->viewModel, "Home", "Index");
}
示例2: hydrateResource
public function hydrateResource()
{
$role = $this->role;
$resources = $role->getResources();
foreach ($resources as $value) {
$this->resources->offsetSet($value, $value);
}
return $this;
}
示例3: offsetSet
public function offsetSet($key, $value)
{
if ((int) $value % 3 === 0 or (int) $value % 5 === 0) {
parent::offsetSet($key, $value);
}
return;
}
示例4: offsetSet
/**
* Sets a collection entry
*
* @param string $index
* @param string $content
*
* @throws \MarkdownExtended\Exception\UnexpectedValueException it the argument does not implement `\MarkdownExtended\API\ContentInterface`
*/
public function offsetSet($index, $content)
{
if (!is_object($content) || !Kernel::valid($content, Kernel::TYPE_CONTENT)) {
throw new UnexpectedValueException(sprintf('Method "%s" expects the second parameter to implement "%s", got "%s"', __METHOD__, Kernel::CONTENT_INTERFACE, is_object($content) ? get_class($content) : gettype($content)));
}
parent::offsetSet($index, $content);
}
示例5: offsetSet
/**
* Set object
*
* @param mixed $index
* @param Currency $newval
*/
public function offsetSet($index, $newval)
{
if (!$newval instanceof $this->currencyClass) {
throw new \InvalidArgumentException(sprintf('$newval must be an instance of Currency, instance of "%s" given', get_class($newval)));
}
parent::offsetSet($index, $newval);
}
示例6: offsetSet
/**
*/
public function offsetSet($offset, $value)
{
if (is_null($roffset = $this->_getRealOffset($offset))) {
parent::offsetSet($offset, $value);
} else {
parent::offsetSet($roffset, $value);
}
}
示例7: collect
public function collect(\Iterator $iterator) : \Traversable
{
$collection = new \ArrayIterator();
foreach ($iterator as $key => $value) {
$collection->offsetSet($key, $value);
}
return $collection;
}
示例8: offsetSet
/**
* (PHP 5 >= 5.0.0)<br/>
* Set value for an offset
*
* @link http://php.net/manual/en/arrayiterator.offsetset.php
*
* @param string $index <p>
* The index to set for.
* </p>
* @param string $newval <p>
* The new value to store at the index.
* </p>
*
* @throws Exception\Collection When the collection has been marked as read-only
* @throws Exception\Collection When the given type is not correct
*/
public function offsetSet($index, $newval)
{
if ($this->isReadOnly() === true) {
throw Exception\Collection::readOnly(get_class($this));
}
if ($this->isValidValue($newval) === false) {
throw Exception\Collection::invalidType($newval, get_class($this));
}
parent::offsetSet($index, $newval);
}
示例9: reflect
/**
* Reflect the handle class
*
* @param string $class
* @return Collection\Method
* @throws Exception\InvalidArgument
*/
public function reflect($class)
{
if (class_exists($class) === false) {
throw new Exception\InvalidArgument(sprintf($this->exceptions[1], $class), 1);
}
// Check if we've already reflected this class
if (static::$reflections->offsetExists($class)) {
return static::$reflections->offsetGet($class);
}
// Create reflection
$reflectionClass = new \ReflectionClass($class);
$reflectionMethods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC);
// Method container
$methods = new Collection\Method();
// Loop through the class methods (Only public);
foreach ($reflectionMethods as $reflectionMethod) {
// Create method information entity
$method = new Entity\Method();
$method->setName($reflectionMethod->getName());
// Get method parameters
$reflectionParams = $reflectionMethod->getParameters();
// Evaluate the method params
foreach ($reflectionParams as $reflectionParam) {
// Create parameter information entity
$parameter = new Entity\Parameter();
$parameter->setIndex($reflectionParam->getPosition());
$parameter->setName($reflectionParam->getName());
$parameter->setRequired($reflectionParam->isDefaultValueAvailable() === false);
// Only set default value when param is optional
if ($parameter->getRequired() === false) {
$parameter->setDefault($reflectionParam->getDefaultValue());
}
// Add the parameter to the container
$method->addParameter($parameter);
}
// Add the method to the method container
$methods->offsetSet(strtolower($method->getName()), $method);
}
// Cache reflection in the runtime
self::$reflections->offsetSet($class, $methods);
// Return the methods
return $methods;
}
示例10: extractArray
/**
* Extract array of var in object
* @param Object $object
* @returns array Array extracted of the object
*/
public function extractArray($object, $isRecursive = false)
{
if (method_exists($object, "toArray")) {
return $object->toArray();
}
$arrayCollection = new \ArrayIterator();
$reflection = new \ReflectionClass($object);
$vars = array_keys($reflection->getdefaultProperties());
foreach ($vars as $key) {
$value = $this->resolveGetNameMethod($key, $object);
if ($value !== null) {
if (is_object($value) && !$isRecursive) {
$arrayCollection->offsetSet($key, $this->extractArray($value, true));
} else {
$arrayCollection->offsetSet($key, $value);
}
}
}
return $arrayCollection->getArrayCopy();
}
示例11: getAnnotations
/**
* Get Annotations Found
*
* @return array
* Found Annotations
*/
public function getAnnotations()
{
$data = new \ArrayIterator();
$domains = $this->matchDomainAnnotations($this->application);
if (count($domains) > 0) {
$data->offsetSet('Domains', $domains);
}
$data->offsetSet('Path', $this->matchPathAnnotation($this->application));
// Listing Controllers Methods and reducing (or amplifying) the list to its Action Methods
$actions = $this->application->getControllers()->getIterator();
iterator_apply($actions, function (\Iterator $iterator) {
$action = new Actions(new \ArrayIterator($iterator->current()->getClass()->getMethods()));
$iterator->offsetSet($iterator->key(), $action->getAnnotations());
return TRUE;
}, array($actions));
if ($actions->count() > 0) {
$data->offsetSet('Routes', $actions->getArrayCopy());
}
return $data;
}
示例12: getHandler
/**
* Get the handler based on the namespace
*
* @param string $namespace
* @return object
* @throws Exception\ArgumentException
*/
protected function getHandler($namespace)
{
// Chack if namespace has been registered
if ($this->handlers->offsetExists($namespace) === false) {
throw new Exception\InvalidArgument(sprintf($this->exceptions[1], $namespace), 1);
}
// Create instance when needed
if ($this->handlerInstances->offsetExists($namespace) === false) {
$handler = $this->handlers->offsetGet($namespace);
$this->handlerInstances->offsetSet($namespace, new $handler());
}
// Return instance
return $this->handlerInstances->offsetGet($namespace);
}
示例13: addRequest
public function addRequest(EntityRequest $request, $callable = null)
{
$id = $request->getId();
if ($id === null && $callable !== null) {
throw new Exception\InvalidArgument('Request ID is NULL. This means no response for server. Cannot ' . 'attach callable to this request.', 1);
}
if ($id !== null && array_key_exists($id, $this->ids)) {
throw new Exception\RuntimeException('Cannot add same id `' . $id . '` twice to the stack!');
}
// Add the callable to the stack
if ($id !== null) {
$this->ids[$id] = $callable;
}
return parent::offsetSet(null, $request);
}
示例14: Search
function Search()
{
$arry = new ArrayIterator();
$chkOptionType = Request::RequestParams("rbticketType");
$txtForm = Request::RequestParams("txtForm");
$txtTo = Request::RequestParams("txtTo");
$txtDepatureDate = Request::RequestParams("txtDepatureDate");
$txtreturndate = Request::RequestParams("txtreturndate");
$sltflight = Request::RequestParams("sltflight");
$sltTicketType = Request::RequestParams("sltTicketType");
$txtadults = Request::RequestParams("txtadults");
$txtchildren = Request::RequestParams("txtchildren");
Session::set("children", $txtchildren);
Session::set("adults", $txtadults);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
//search on flights base on the given informations
$this->db = new Database();
$statement = "select *from tbl_flight where to_where =:to_where or from_where=:from_where or " . " landingDate =:landingDate or BoardDate =:BoardDate or BoardingTime =:BoardingTime or " . " price =:price ";
$smt = $this->db->prepare($statement);
$smt->bindValue(":to_where", $txtTo);
$smt->bindValue(":from_where", $txtForm);
$smt->bindValue(":landingDate", $statement);
$smt->bindValue(":BoardDate", $txtDepatureDate);
$smt->bindValue(":BoardingTime", $txtreturndate);
$smt->bindValue(":price", $statement);
$status = $smt->execute();
if (!$status) {
print_r($smt->errorInfo());
}
//get all the results
// $flight= new Flight();
Session::set("Searching", "1");
$counter = 0;
while ($row = $smt->fetch(PDO::FETCH_ASSOC)) {
$flight = new Flight();
$flight->Id = $row["id"];
$flight->Landingtime = $row["LandingTime"];
$flight->boardingTime = $row["BoardingTime"];
$flight->deptureDate = $row["BoardDate"];
$flight->from = $row["from_where"];
$flight->landindDate = $row["landingDate"];
$flight->stops = $row["noofstop"];
$flight->ticketPrice = $row["price"];
$flight->to = $row["to_where"];
$flight->seats = $row["seats"];
$flight->status = $row["status"];
$flight->planeID = $row["planeID"];
$arry->offsetSet($counter, $flight);
$counter++;
}
}
$this->ViewBag("Title", "Search flight");
$this->ViewBag("Controller", "Flight");
$this->ViewBag("Page", "SearchFlights");
$this->flightModelView->flightList = $arry;
$controller = "Home";
$action = "Index";
ContextManager::PartialView("SearchFlights", "Flight");
Session::set("SubView", "SearchFlights");
return $this->View($this->flightModelView, $controller, $action);
}
示例15: addLocHelper
/**
* @param LocationHelper $locHelper
* @return $this
*/
public function addLocHelper(LocationHelper $locHelper)
{
$this->locations->offsetSet($locHelper->getLoc()["lid"], $locHelper);
return $this;
}