/**
  * Generates a request based on the current apache variables.
  * @throws Exception
  */
 public static function generate()
 {
     $headers = new Map(apache_request_headers());
     $method = $_SERVER['REQUEST_METHOD'];
     $path = $_SERVER['REQUEST_URI'];
     switch ($headers->get('Content-Type', null)) {
         case 'application/json':
             $data = file_get_contents('php://input');
             $values = json_decode($data, true);
             $params = new Map($values);
             break;
         case 'application/x-www-form-urlencoded':
             $params = new Map($_POST);
             break;
         default:
             if ($method === 'GET') {
                 $params = new Map($_GET);
             } else {
                 if ($method === 'POST' || $method === 'PUT') {
                     $params = new Map($_POST);
                 } else {
                     $params = new Map();
                 }
             }
             break;
     }
     return new Request($path, $method, $headers, $params);
 }
예제 #2
0
 /**
  *
  * @param <type> $table
  * @param ArrayIterator $params
  * @return ArrayObject
  */
 public function search($table, ArrayIterator $params)
 {
     $this->searchParams = $params;
     $this->join();
     if ($table == "analysis") {
         $this->statements->remove("type_event");
     }
     $statement = "SELECT this_.* " . $this->selectAttributes() . " FROM {$table} this_ ";
     $statement .= $this->join();
     $i = 0;
     $this->searchParams->rewind();
     if ($this->searchParams->count() > 0 && !$this->searchParams->offsetExists('true')) {
         $statement .= " WHERE ";
     }
     while ($this->searchParams->valid()) {
         if ($this->statements->containsKey($this->searchParams->key())) {
             if ($i++ > 0) {
                 $statement .= " AND ";
             }
             $clause = $this->statements->get($this->searchParams->key());
             $statement .= str_replace(":" . $this->searchParams->key(), "'" . $this->searchParams->current() . "'", $clause['where']);
         }
         $this->searchParams->next();
     }
     return $this->getObject($statement . " ORDER BY this_.date DESC, this_.id DESC");
 }
예제 #3
0
 public function testCopy()
 {
     $copy = $this->properties->copy();
     $copy->set('foo5', 'bar5');
     $this->assertEquals('bar5', $copy->get('foo5'));
     $this->assertEquals(null, $this->properties->get('foo5'));
 }
예제 #4
0
 /**     
  * @param <type> $key
  * @return Provider
  */
 private function selectTypeOf($key)
 {
     if ($this->types->containsKey($key)) {
         return $this->types->get($key);
     }
     return null;
 }
예제 #5
0
 /** @test */
 public function removeAffectsGivenKeyOnly()
 {
     $map = new Map(array('foo' => 42, 'bar' => 1337));
     $map->remove('foo');
     $this->assertFalse($map->hasKey('foo'));
     $this->assertEquals(1337, $map->get('bar'));
 }
 private static function isInstantiable(Clazz $clazz, Map $whitelist)
 {
     if ($clazz->isPrimitive()) {
         return true;
     }
     $instantiable = $whitelist->get($clazz);
     return $instantiable != null && $instantiable;
 }
예제 #7
0
 /**
  * Moves the element from current position to end of array
  *
  * @param int|string $key The key
  * @return LRUMap
  */
 protected function recordAccess($key)
 {
     foreach (parent::get($key) as $value) {
         unset($this->elements[$key]);
         $this->elements[$key] = $value;
     }
     return $this;
 }
예제 #8
0
파일: MapTest.php 프로젝트: haldayne/boost
 /**
  * @dataProvider provides_keys
  */
 public function test_common_and_exotic_keys($key)
 {
     $map = new Map();
     $map->set($key, 'foo');
     $this->assertSame('foo', $map->get($key, 'baz'));
     $this->assertCount(1, $map);
     $map->all(function ($v, $k) use($key) {
         $this->assertSame($key, $k);
     });
 }
예제 #9
0
 /**
  * Checks an relation to the indicated alliance.
  *
  * @param integer|boolean $aid
  *
  * @return mixed	The relation mode or false
  */
 protected function getAllyRelation($aid = false)
 {
     if (!$aid || !$this->aid) {
         return false;
     }
     $this->loadAllianceRelations();
     if ($this->alliances->size() > 0 && $this->alliances->exists($aid)) {
         return $this->alliances->get($aid);
     }
     return false;
 }
예제 #10
0
 public function getLineWithTitles()
 {
     return new ArrayObject($this->values->get("rowTitles"));
 }
예제 #11
0
<?php

// Runs top to bottom (most important should be at the top)
Map::get('/', 'home#index');
예제 #12
0
 private function getNameByCode($code)
 {
     return $this->types->get($code);
 }
예제 #13
0
파일: routes.php 프로젝트: phn007/MyTools
<?php

//Shop Redirect to merchant
Map::get('/', 'home#index');
Map::get('/about-us' . FORMAT, 'staticpage#about');
Map::get('/contact-us' . FORMAT, 'staticpage#contact');
Map::get('/privacy-policy' . FORMAT, 'staticpage#privacy');
Map::get('/brand-index/(.*)', 'brandIndex#index');
Map::get('/cat-by-brand/(.*)', 'brandIndex#catByBrand');
Map::get('/product-by-cat/(.*)', 'brandIndex#productByCategory');
Map::get('/shop', 'shop#index');
Map::get('/shop/categories/(.*)' . FORMAT, 'categories#categories');
Map::get('/shop/brands/(.*)' . FORMAT, 'categories#brands');
Map::get('/shop/category/(.*)' . FORMAT, 'category#category');
Map::get('/shop/brand/(.*)' . FORMAT, 'category#brand');
Map::get('/shop/(.*)', 'product#index');
Map::get('/blog/page/(.*)', 'blog#index');
Map::get('/blog/category/(.*)', 'blog#category');
Map::get('/blog/(.*)', 'blog#article');
Map::get('/search/(.*)', 'search#index');
Map::get('/goto/(.*)', 'goto#index');
Map::get('/error', 'error#index');
Map::get('/(.*)', 'product#index');
예제 #14
0
 public function getFonts()
 {
     return $this->map->get($this->id());
 }
 private function filetypeAllowed($filetype)
 {
     return $this->filetypeAllowed->get($filetype);
 }
예제 #16
0
파일: Match.php 프로젝트: allejo/bzion
 /**
  * Get the map where the match was played on
  * @return Map Returns an invalid map if no map was found
  */
 public function getMap()
 {
     return Map::get($this->map);
 }
예제 #17
0
파일: routes.php 프로젝트: netizen0911/mvc3
<?php

// Runs top to bottom (most important should be at the top)
Map::get('/', 'welcome#index');
Map::resource('welcome');
 /**
  * @dataProvider provider__construct
  */
 public function test_remove($base, $diff)
 {
     $map = new Map($base);
     foreach ($base as $key => $value) {
         $this->assertEquals($map->get($key), $value);
     }
     foreach ($diff as $key => $value) {
         $map->remove($key);
         unset($base[$key]);
     }
     foreach ($base as $key => $value) {
         $this->assertEquals($map->get($key), $value);
     }
 }
예제 #19
0
<?php

Map::get('/', 'welcome#index');
Map::get('/404', 'error_controller#error_index');