Skip to content

Commit

Permalink
remove HasOneSql::withTitle
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Nov 9, 2021
1 parent 6943787 commit 70e8c52
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 29 deletions.
2 changes: 1 addition & 1 deletion docs/model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ Title Field
you can specify that in the property. If title_field is not needed, set it
to false or point towards a non-existent field.

See: :php:meth::`hasOne::addTitle()` and :php:meth::`hasOne::withTitle()`
See: :php:meth::`hasOne::addTitle()`

.. php:method:: public getTitle
Expand Down
4 changes: 0 additions & 4 deletions docs/sql.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ SQL Reference

Returns new field object.

.. php:method:: withTitle
Similar to addTitle, but returns $this.

Expressions
-----------

Expand Down
2 changes: 0 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ parameters:
- '~^Call to an undefined method Atk4\\Data\\Reference\\HasOne::addTitle\(\)\.$~'
# for tests/JoinSqlTest.php
- '~^Call to an undefined method Atk4\\Data\\Reference\\HasOne::addField\(\)\.$~'
# for tests/LookupSqlTest.php
- '~^Call to an undefined method Atk4\\Data\\Reference\\HasOne::withTitle\(\)\.$~'
# for tests/ReferenceSqlTest.php
- '~^Call to an undefined method Atk4\\Data\\Reference\\HasOne::addFields\(\)\.$~'
- '~^Call to an undefined method Atk4\\Data\\Reference::addTitle\(\)\.$~'
Expand Down
16 changes: 0 additions & 16 deletions src/Reference/HasOneSql.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,20 +219,4 @@ function (Model $ourModel) {

return $fieldExpression;
}

/**
* Add a title of related entity as expression to our field.
*
* $order->hasOne('user_id', 'User')->addTitle();
*
* This will add expression 'user' equal to ref('user_id')['name'];
*
* @return $this
*/
public function withTitle(array $defaults = [])
{
$this->addTitle($defaults);

return $this;
}
}
6 changes: 3 additions & 3 deletions tests/LookupSqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ protected function init(): void
$this->addField('name');
$this->addField('is_vip', ['type' => 'boolean', 'default' => false]);

$this->hasOne('country_id', ['model' => [LCountry::class]])
->withTitle()
->addFields(['country_code' => 'code', 'is_eu']);
$ref = $this->hasOne('country_id', ['model' => [LCountry::class]])
->addFields(['country_code' => 'code', 'is_eu'])
->addTitle();

$this->hasMany('Friends', ['model' => [LFriend::class]])
->addField('friend_names', ['field' => 'friend_name', 'concat' => ',']);
Expand Down
2 changes: 1 addition & 1 deletion tests/RandomTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected function init(): void
$this->addField('age');
$i2 = $this->join('item2.item_id');
$i2->hasOne('parent_item_id', ['model' => $m, 'table_alias' => 'parent'])
->withTitle();
->addTitle();

$this->hasMany('Child', ['model' => $m, 'their_field' => 'parent_item_id', 'table_alias' => 'child'])
->addField('child_age', ['aggregate' => 'sum', 'field' => 'age']);
Expand Down
4 changes: 2 additions & 2 deletions tests/ScopeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ protected function init(): void
$this->addField('is_vip', ['type' => 'boolean', 'default' => false]);

$this->hasOne('country_id', ['model' => [SCountry::class]])
->withTitle()
->addFields(['country_code' => 'code', 'is_eu']);
->addFields(['country_code' => 'code', 'is_eu'])
->addTitle();

$this->hasMany('Tickets', ['model' => [STicket::class], 'their_field' => 'user']);
}
Expand Down

0 comments on commit 70e8c52

Please sign in to comment.