Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions modules/Application/src/Application/Controllers/timeline.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
namespace Application\controllers;

use Application\Services;

// if(!isset($_SESSION['email']))
// header("Location: /home/select");

class Timeline
{
public $layout = null;

public function index()
{
$id = \Core\Application\Application::getRequest()['id'];
$service = new Services\Timeline();
$data = $service->{strtolower($_SERVER['REQUEST_METHOD'])}($id);

header('Content-Type: application/json');
echo json_encode($data);
}

}
44 changes: 16 additions & 28 deletions modules/Application/src/Application/Mappers/Timeline.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php
namespace Application\Mappers;

use Core\Application\Application;
use Application\Models\EntityTimeline;

class Timeline
{
private $adapterName;
Expand All @@ -30,7 +28,6 @@ public function setId($id)
{
$this->id = $id;
}

/**
*
* @return array de users
Expand All @@ -50,7 +47,6 @@ public function fetchAllTimeline()
$tag = $adapter->fetchAll();

$timelineHidrateds = array();

for($i=0; $i < sizeof($timeline); $i++)
{
/**
Expand All @@ -60,9 +56,7 @@ public function fetchAllTimeline()
$timelineHidrated->hydrate($timeline[$i]);
array_push($timelineHidrateds, $timelineHidrated->extract());
}

$adapter->disconnect();

return $timelineHidrateds;
break;
case'\Core\Adapters\Txt':
Expand All @@ -88,12 +82,7 @@ public function fetchTimeline()
return $userHidrated->extract();
}
}
<<<<<<< HEAD

public function updateTimeline()
{

=======

/**
* @param array $data
Expand All @@ -114,29 +103,28 @@ public function insertTimeline($data)
$adapter->disconnect();
return $timeline;
}
>>>>>>> dd76ab8df412560853061c423b655541875279b0
}

/**
* @param none, use before setId()
* @return unknown
*/
public function deleteTimeline()
public function deleteTimeline($id)
{
switch($this->adapterName){
case'\Core\Adapters\Mysql':
$adapter = new $this->adapterName();
$adapter->setTable("timeline");
/**
* TODO Relacion entre el nombre de las variables de la entity y el de la tabla
*/
$timeline = $adapter->delete(array('idTimeline'=> $this->id));
/**
* TODO Falta el idTag con el Title del Media
*/
$adapter->disconnect();
return $timeline;
}
$adapter = new $this->adapterName();
if(method_exists($adapter, 'setTable')){
$adapter->setTable("timeline");
}

/**
* TODO Relacion entre el nombre de las variables de la entity y el de la tabla
*/
$timeline = $adapter->delete(array('id_timeline'=> $id));
/**
* TODO Falta el idTag con el Title del Media
*/
$adapter->disconnect();
return $timeline;
}

/**
Expand All @@ -160,4 +148,4 @@ public function updateTimeline($data)
return $timeline;
}
}
}
}
54 changes: 54 additions & 0 deletions modules/Application/src/Application/Mappers/Types.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
//Mapper to table types (Timeline)
namespace Application\Mappers;

class Types{

private $adapterName;

/**
* Constructor que al instanciar recibe el adapter
*/
public function __construct()
{
$config = Application::getConfig();
$request = Application::getRequest();
$this->setAdapterName($config['adapter']);
if(isset($request['params']['id']))
$this->setId($request['params']['id']);
}

public function setAdapterName($adapterName)
{
$this->adapterName = $adapterName;
}

/**
*
* @return array de users
*/
public function fetchAll()
{


}

public function fetch()
{

}

public function insert()
{

}

public function delete($id)
{
$adapter = new $this->adapterName();
if(method_exists($adapter, 'setTable')){
$adapter->setTable('tag');
}
return $adapter->delete($id);
}
}
6 changes: 3 additions & 3 deletions modules/Application/src/Application/Services/Timeline.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Application\Services;

use Application\Mappers\Timeline as TimelineMapper;

/**
* TODO No me reconoce el TimelineMapper
*/
Expand Down Expand Up @@ -58,8 +58,8 @@ public function delete($id)
{
$mapper = new TimelineMapper();
//FILA 3
$mapper->setId($id);
$ok = $mapper->deleteTimeline();
$ok = $mapper->deleteTimeline($id);
return $ok;
if (!$ok)
die("POST Method failure");
}
Expand Down