示例#1
0
 public function login(Request $request)
 {
     $credentials = $request->only(['email', 'password']);
     $user = $this->authService->loginWithCredentials($credentials);
     $encodedToken = $this->tokenService->requestAccessToken($user);
     $jsonUser = $this->jsonTransformer->item($user, new UserTransformer());
     return $this->respondOk(['user' => $jsonUser, 'token' => $encodedToken->toString()]);
 }
示例#2
0
 public function scrap()
 {
     // $html = file_get_contents(base_path('resources/views/dse.php'));
     $downloader = new Downloader();
     $parser = new Parser();
     $transformer = new Transformer();
     $html = $downloader->download();
     $data = $parser->parse($html);
     $data = $transformer->transform($data);
     return $data;
 }
示例#3
0
文件: Item.php 项目: wisoot/restify
 /**
  * convert method
  *
  * @param $entity
  * @param array $embeds
  * @return array
  */
 public function transform($entity, array $embeds = [])
 {
     $data = $this->transformer->transform($entity);
     foreach ($embeds as $embed) {
         if (isset($entity->{$embed->name}) && method_exists($this->transformer, $embed->name)) {
             $resource = $this->transformer->{$embed->name}();
             $data[$embed->name] = $resource->transform($entity->{$embed->name}, $embed->children);
         }
     }
     return $data;
 }
 public function testTransform()
 {
     $map = array('id' => 'productId', 'name' => 'name', 'price' => 'unitPrice');
     $product = new Fixtures\Product();
     $product->setId('product-1');
     $product->setName('T-Shirt');
     $product->setPrice(44.99);
     $transformer = new Transformer();
     $transformer->setTransformationMap($map);
     $lineItem = $transformer->transform($product, 'Transform\\Fixtures\\LineItem');
     $this->assertEquals($product->getId(), $lineItem->getProductId());
     $this->assertEquals($product->getName(), $lineItem->getName());
     $this->assertEquals($product->getPrice(), $lineItem->getUnitPrice());
 }
示例#5
0
 public function __construct($value, $sanitize = false)
 {
     if ($sanitize) {
         $value = filter_var($value, FILTER_SANITIZE_URL);
     }
     parent::__construct($value);
 }
 /**
  * Tests whether the generateFilename method returns a file according to
  * the right format.
  *
  * @covers phpDocumentor\Transformer\Transformer::generateFilename
  *
  * @return void
  */
 public function testGenerateFilename()
 {
     // separate the directories with the DIRECTORY_SEPARATOR constant to
     // prevent failing tests on windows
     $filename = 'directory' . DIRECTORY_SEPARATOR . 'directory2' . DIRECTORY_SEPARATOR . 'file.php';
     $this->assertEquals('directory.directory2.file.html', $this->fixture->generateFilename($filename));
 }
示例#7
0
 /**
  * transformOnce method
  *
  * @param mixed $input
  * @param array $embeds
  * @return array
  */
 protected function transformOnce($input, array $embeds = [])
 {
     if ($this->transformer === null) {
         $this->transformer = $this->provider->willTransform($input)->get();
     }
     return $this->transformer->transform($input, $embeds);
 }
示例#8
0
 public function getEntityWithLowerPosition(Page $movedEntity)
 {
     $criteria = new SelectCriteria($this->getDomain());
     $criteria->setCriteria(Criterion::_gt($this->getDomain(), "position", $movedEntity->getPosition()));
     $criteria->addTransformer(Transformer::_limit(1));
     $criteria->addTransformer(Transformer::_orderBy($this->getDomain(), "position", false));
     return $criteria->toUnique();
 }
示例#9
0
function process($tag)
{
    global $dir;
    if (!file_exists($dir . $tag)) {
        return false;
    }
    $file = $dir . $tag;
    $handle = fopen($file, "r");
    $tokenstream = (new Tokenizer($handle))->tokenize();
    $parser = new Parser();
    $parser->parse($tokenstream);
    global $tree;
    $xml = $tree->toXML($file);
    $info = pathinfo($file);
    $xmlFile = $info["dirname"] . "/" . $info["filename"] . ".xml";
    $transformer = new Transformer($xmlFile);
    echo $transformer->transform();
}
示例#10
0
 public function __construct($value, $padValue, $padAmount, $padType)
 {
     parent::__construct($value);
     if ($padType != STR_PAD_RIGHT && $padType != STR_PAD_LEFT && $padType != STR_PAD_BOTH) {
         throw new \InvalidArgumentException("Invalid pad side option");
     }
     $this->padValue = $padValue;
     $this->padType = $padType;
     $this->padAmount = $padAmount;
 }
 public function getEntityWithLowerPosition(PageComponent $movedEntity)
 {
     $criteria = new SelectCriteria($this->getDomain());
     $positionCriteria = Criterion::_gt($this->getDomain(), "position", $movedEntity->getPosition());
     $columnCriteria = Criterion::_eq($this->getDomain(), "pageColumnId", $movedEntity->getPageColumnId());
     $criteria->setCriteria(Criterion::_and($positionCriteria, $columnCriteria));
     $criteria->addTransformer(Transformer::_limit(1));
     $criteria->addTransformer(Transformer::_orderBy($this->getDomain(), "position", false));
     return $criteria->toUnique();
 }
示例#12
0
 public function __construct($value, $appendValue)
 {
     parent::__construct($value);
     $this->appendValue = $appendValue;
     $this->setPreAppend(false);
 }
 public function __construct($parent = null)
 {
     parent::__construct($parent, "string_to_float");
 }
示例#14
0
# page data
$page_obj->add("script", $_SERVER["SCRIPT_NAME"]);
$page_obj->add("lang", $lang);
$page_obj->add("order", $order);
$page_obj->add("ordertype", $ordertype);
if ($scroll) {
    $page_obj->add("scroll", $scroll);
}
if ($httpParam->cmd()) {
    $page_obj->add("cmd", $httpParam->cmd());
}
# authentivication data
if (isset($_SESSION["logged"])) {
    $page_obj->add("auth", $_SESSION["logged"]);
    $page_obj->add("user", $_SESSION["user"]);
}
# page call id
if ($httpParam->id()) {
    $page_obj->add("id", $httpParam->id());
    $page_obj->add_parameter(["id" => $httpParam->id()]);
}
# timeout parameters
if (isset($_timeout)) {
    $page_obj->add("timeout", $_timeout["time"]);
    $page_obj->add("timeoutpage", $_timeout["page"]);
}
// get parameters for transformation
$param = $page_obj->getarray();
//  debug($param);
$output = new Transformer($xml, "page/" . $page . "/" . $skin . ".xslt", $param);
echo $output->data();
示例#15
0
 public function __construct($value, $delimiter)
 {
     parent::__construct($value);
     $this->delimiter = $delimiter;
 }
示例#16
0
 public function transform($object)
 {
     $seedData = parent::transform($object);
     $seedData['key'] = $object->id;
     return $seedData;
 }
示例#17
0
 public function __construct($parent = null, $separator = "-", $position = 1)
 {
     parent::__construct($parent, "tokenize", array($separator, $position));
 }
示例#18
0
 public function __construct($value, $suffix)
 {
     parent::__construct($value);
     $this->suffix = $suffix;
 }
示例#19
0
 public function __construct($value, $needle)
 {
     parent::__construct($value);
     $this->needle = $needle;
 }
示例#20
0
 public function __construct($value, $allowableTags = '')
 {
     parent::__construct($value);
     $this->allowableTags = $allowableTags;
 }
 public function __construct($parent = null)
 {
     parent::__construct($parent, "float_to_string");
 }
示例#22
0
 public function __construct($parent = null)
 {
     parent::__construct($parent, "urldecode");
 }
示例#23
0
 public function __construct($value, $start, $length = null)
 {
     parent::__construct($value);
     $this->start = $start;
     $this->length = $length;
 }
 /**
  * Constructor.
  *
  * @param array $attributes [optional]
  */
 public function __construct(array $attributes = [])
 {
     parent::__construct($attributes);
 }
示例#25
0
 public function __construct($value, $decode = false)
 {
     parent::__construct($value);
     $this->decode = $decode;
 }
示例#26
0
 public function getConfirmedCompanies($page, $rowCount)
 {
     $criteria = $this->getCompaniesWithStatusCriteria(2);
     $criteria->addTransformer(Transformer::_limit($page * $rowCount, $rowCount));
     return $criteria->toArray();
 }
示例#27
0
 public function __construct($parent = null)
 {
     parent::__construct($parent, "to_upper");
 }
示例#28
0
 public function __construct($value, $left, $right)
 {
     parent::__construct($value);
     $this->left = $left;
     $this->right = $right;
 }
示例#29
0
 public function __construct($value)
 {
     parent::__construct($value);
 }
示例#30
0
 public function __construct($value, $prefix)
 {
     parent::__construct($value);
     $this->prefix = $prefix;
 }