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