Add Model\Introduction class to DI registry
This commit is contained in:
parent
2cb449a0d5
commit
df0c05d635
5 changed files with 10 additions and 15 deletions
|
@ -31,9 +31,7 @@ function notifications_post(App $a)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request_id) {
|
if ($request_id) {
|
||||||
/** @var Introduction $Intro */
|
$Intro = DI::intro()->fetch(['id' => $request_id, 'uid' => local_user()]);
|
||||||
$Intro = \Friendica\BaseObject::getClass(Introduction::class);
|
|
||||||
$Intro->fetch(['id' => $request_id, 'uid' => local_user()]);
|
|
||||||
|
|
||||||
switch ($_POST['submit']) {
|
switch ($_POST['submit']) {
|
||||||
case L10n::t('Discard'):
|
case L10n::t('Discard'):
|
||||||
|
|
|
@ -32,10 +32,11 @@ abstract class BaseModel
|
||||||
*/
|
*/
|
||||||
private $data = [];
|
private $data = [];
|
||||||
|
|
||||||
public function __construct(Database $dba, LoggerInterface $logger)
|
public function __construct(Database $dba, LoggerInterface $logger, $data = [])
|
||||||
{
|
{
|
||||||
$this->dba = $dba;
|
$this->dba = $dba;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
|
$this->data = $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,15 +72,13 @@ abstract class BaseModel
|
||||||
*/
|
*/
|
||||||
public function fetch(array $condition)
|
public function fetch(array $condition)
|
||||||
{
|
{
|
||||||
$intro = $this->dba->selectFirst(static::$table_name, [], $condition);
|
$data = $this->dba->selectFirst(static::$table_name, [], $condition);
|
||||||
|
|
||||||
if (!$intro) {
|
if (!$data) {
|
||||||
throw new HTTPException\NotFoundException(static::class . ' record not found.');
|
throw new HTTPException\NotFoundException(static::class . ' record not found.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->data = $intro;
|
return new static($this->dba, $this->logger, $data);
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -29,6 +29,7 @@ use Psr\Log\LoggerInterface;
|
||||||
* @method static Core\Session\ISession session()
|
* @method static Core\Session\ISession session()
|
||||||
* @method static Database\Database dba()
|
* @method static Database\Database dba()
|
||||||
* @method static Model\Notify notify()
|
* @method static Model\Notify notify()
|
||||||
|
* @method static Model\Introduction intro()
|
||||||
* @method static Protocol\Activity activity()
|
* @method static Protocol\Activity activity()
|
||||||
* @method static Util\ACLFormatter aclFormatter()
|
* @method static Util\ACLFormatter aclFormatter()
|
||||||
* @method static Util\DateTimeFormat dtFormat()
|
* @method static Util\DateTimeFormat dtFormat()
|
||||||
|
@ -61,6 +62,7 @@ abstract class DI
|
||||||
'session' => Core\Session\ISession::class,
|
'session' => Core\Session\ISession::class,
|
||||||
'dba' => Database\Database::class,
|
'dba' => Database\Database::class,
|
||||||
'notify' => Model\Notify::class,
|
'notify' => Model\Notify::class,
|
||||||
|
'intro' => Model\Introduction::class,
|
||||||
'activity' => Protocol\Activity::class,
|
'activity' => Protocol\Activity::class,
|
||||||
'aclFormatter' => Util\ACLFormatter::class,
|
'aclFormatter' => Util\ACLFormatter::class,
|
||||||
'dtFormat' => Util\DateTimeFormat::class,
|
'dtFormat' => Util\DateTimeFormat::class,
|
||||||
|
|
|
@ -30,9 +30,7 @@ class FollowRequests extends Api
|
||||||
{
|
{
|
||||||
parent::post($parameters);
|
parent::post($parameters);
|
||||||
|
|
||||||
/** @var Introduction $Intro */
|
$Intro = DI::intro()->fetch(['id' => $parameters['id'], 'uid' => self::$current_user_id]);
|
||||||
$Intro = self::getClass(Introduction::class);
|
|
||||||
$Intro->fetch(['id' => $parameters['id'], 'uid' => self::$current_user_id]);
|
|
||||||
|
|
||||||
$contactId = $Intro->{'contact-id'};
|
$contactId = $Intro->{'contact-id'};
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,7 @@ class FollowConfirm extends BaseModule
|
||||||
$duplex = intval($_POST['duplex'] ?? 0);
|
$duplex = intval($_POST['duplex'] ?? 0);
|
||||||
$hidden = intval($_POST['hidden'] ?? 0);
|
$hidden = intval($_POST['hidden'] ?? 0);
|
||||||
|
|
||||||
/** @var Introduction $Intro */
|
$Intro = DI::intro()->fetch(['id' => $intro_id, 'uid' => local_user()]);
|
||||||
$Intro = self::getClass(Introduction::class);
|
|
||||||
$Intro->fetch(['id' => $intro_id, 'uid' => local_user()]);
|
|
||||||
|
|
||||||
$cid = $Intro->{'contact-id'};
|
$cid = $Intro->{'contact-id'};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue